I am trying to place a dialog in the center of the screen based on a users
screen resolution.
I can get the width and height of the screen, but I can't seem to use the
following:
root.geometry(' WxH+X+Y')
It appears the values for X and Y need to be integers and not a variable
like width/2-40
S 5 2599
Tkinter takes strings as its arguments; it's TCL's legacy. You can use
string formatting for this:
x = width/2-40
y = height/2-30
root.geometry(' %ldx%ld+%ld+%ld ' % (width, height, x, y))
Thanks.
S
"Lonnie Princehouse" <fi************ **@gmail.com> wrote in message
news:11******** *************@v 46g2000cwv.goog legroups.com... Tkinter takes strings as its arguments; it's TCL's legacy. You can use string formatting for this:
x = width/2-40 y = height/2-30
root.geometry(' %ldx%ld+%ld+%ld ' % (width, height, x, y))
"Pat" <pa******@adelp hia.net> wrote: I am trying to place a dialog in the center of the screen based on a users screen resolution. I can get the width and height of the screen, but I can't seem to use the following:
root.geometry(' WxH+X+Y')
It appears the values for X and Y need to be integers and not a variable like width/2-40
Python doesn't look in string literals for things that might look
like expressions, but if you have the values, *creating* a string
with the right contents is pretty easy. see the tutorial for the
basics: http://docs.python.org/tut/node9.html
if you have all the values in variables, this expression sets the
geometry in one step:
root.geometry(" %dx%d%+d%+d" % (width, height, xoffset, yoffset))
also see http://effbot.org/tkinterbook/wm.htm...eometry-method
which includes code that parses a geometry string.
</F>
Lonnie Princehouse wrote: Tkinter takes strings as its arguments; it's TCL's legacy.
geometry strings are an X windows thing...
You can use string formatting for this:
x = width/2-40 y = height/2-30
root.geometry(' %ldx%ld+%ld+%ld ' % (width, height, x, y))
note that "+%ld" (why bother with the l, btw? Python's not C) will
misbehave if you pass in a negative offset. better use "%+d".
</F>
Thanks a lot for you response.
S
"Fredrik Lundh" <fr*****@python ware.com> wrote in message
news:ma******** *************** *************** *@python.org... "Pat" <pa******@adelp hia.net> wrote:
I am trying to place a dialog in the center of the screen based on a users screen resolution. I can get the width and height of the screen, but I can't seem to use the following:
root.geometry(' WxH+X+Y')
It appears the values for X and Y need to be integers and not a variable like width/2-40
Python doesn't look in string literals for things that might look like expressions, but if you have the values, *creating* a string with the right contents is pretty easy. see the tutorial for the basics:
http://docs.python.org/tut/node9.html
if you have all the values in variables, this expression sets the geometry in one step:
root.geometry(" %dx%d%+d%+d" % (width, height, xoffset, yoffset))
also see
http://effbot.org/tkinterbook/wm.htm...eometry-method
which includes code that parses a geometry string.
</F> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: MSE |
last post by:
How can I make a website that adapts to the screen resolution? I would
also like to include a picture that stretches when the screen res.
increases, if you know what I mean.
|
by: Chris |
last post by:
After exhausting my search on the MS website, I can't find a straight answer.
I fin dit hard to believe that MS left our something so useful in ASP.NET as
screen resolution detection.
Problem:
I would like to detect, get values for, the screen resolution in px but in a
code behind. Is this possible?
There is a System.Windows.Forms.Screen class for the Windows client side,
why are there none for browser/ASP.NET client?
|
by: Les Juby |
last post by:
I understand that there are several ways to effectively control the
browser delivery of HTML to make the most effective use of the
different screen resolutions today. (And in the foreseeable future...)
I have a client with a text based site (displays a lot of labour law)
which is being read in a range of resolutions and he wants a rewrite
as a long term solution to browser resolution compatibility.
My thinking goes........
|
by: jlombardo |
last post by:
I've read previous posts and know it is "bad form" to change a user's
screen resolution to fit your program's needs. My situation is very
different.
I have a user with a laptop resolution of 1680x1050. When they dock
the laptop, the external monitor connects and uses 1900x1200
resolution.
They need a program to do the following:
1 - Detect the current screen resolution.
|
by: VJ |
last post by:
Is there a any known easy way to fit web pages for a screen resolution. Can
I do this programmatically?
VJ
| |
by: Robert Bull |
last post by:
I have created an asp.net app on my machine where the resolution is
set to 1280 x 1024. When my users view the form on their screen, some
of the controls display differently than on my screen. One solution I
have is to use some javascript to determine the resolution of their
screen and redirect them to a duplicate form suited better for their
resolution but I would have to maintain multiple forms. Anybody know
of a better way to handle...
|
by: Agnes |
last post by:
MY application is designed based on 800 X600 screen size.
However, some client use 1024 X768 , When they run the application, the form
become smaller.
I don't want to re-wrtie all the forms
How can I enlarge the form to fit the 1024 X768 ??
thanks a lot
|
by: Mufasa |
last post by:
I have some machines that apparently are having the screen resolution
changed based on group policies ( this is what my Network Engineer is
telling me ). These machines are at customer sites so we can't see what it
going on.
The problem is, or at least appears to be, that the code is returning
different dimensions then what is really out there. The code I'm using to
find out the dimensions is:
System.Drawing.Rectangle workingRectangle...
|
by: mikek12004 |
last post by:
I want to load a different swf in PHP based on the viewer's screen resolution. All would be fine if I could get the screen resolution in a variable in PHP. Problem is that after I done a bit of a digging that this can be only done through javascript(or so most claim) and to pass the resolution from javascript to PHP you would need to refresh the page again (to put the resolution in the URL or in a coockie) The other solution is to use ajax and...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |