[PythonCE] Screen size?
Stewart Midwinter
stewart.midwinter at gmail.com
Fri Feb 4 06:07:07 CET 2005
Miles:
The python2.3.4.zip file has a python.exe that's designed for 240x320
screen, but there is another python.exe floating around that will
support 480x640. But that doesn't help you, I know.
In your case, it sounds as though you've started up an app and gotten
your root window a little too large for your screen. You can tune it
as follows: use the attached little app I prepared, screenTuner.py.
It will display current screen resolution, current root window size,
and allow you to make changes to your window size and see the effect.
cheers,
S
On Thu, 03 Feb 2005 16:13:14 -0500, Miles Lubin <miles at lubin.us> wrote:
> I'm just playing around and trying to get my python program to work on
> my pocket pc.
> It's working great after using the input function posted on this list in
> september, but the one problem is that the window seems to be hardcoded
> for a size bigger than my screen, I have an Axim X5. This makes the
> horizontal scroll bar partly usable, but the vertical scroll bar is off
> the screen. This didn't happen with the pocket pc python 2.2 from
> MurkWorks... Any way to fix this? Please reply as soon as possible, as I
> am planning on presenting this programin two days.
--
Stewart Midwinter
stewart at midwinter.ca
stewart.midwinter at gmail.com
-------------- next part --------------
#screenTuner.py
#by Stewart Midwinter, 2005-02-03, stewart 'at' midwinter 'dot' ca
import sys, thread, string, os, time
from socket import *
global geometry
global ent1, ent2
global sizex, sizey, startx, starty, xmax, ymax
sizex = 240; sizey = 240 #default values
startx = 0; starty = 0 #default values
ent1 = None; ent2 = None #default values
OS = os.name.lower()
if OS == 'ce':
import pythonrc #contains the sys.path.append() commands
else:
# we are on the desktop
sys.path.append('c:\\programs')
import Tkinter
root = Tkinter.Tk()
root.title('Screen Tuner')
if OS == 'ce':
xmax, ymax = root.wm_maxsize()
sizex, sizey = xmax, ymax
startx = 0; starty = 0
sizex = sizex - startx -6
sizey = sizey - starty -6
else:
# we're not in CE, maybe in Windows instead
xmax, ymax = root.wm_maxsize()
sizex, sizey = (xmax/2, ymax/2)
startx = xmax/4; starty = ymax/4
def update(sizex,sizey):
print 'updating with %sx%s' % (sizex, sizey)
sizex_new = ent1.get()
sizey_new = ent2.get()
if len(sizex_new) > 0 and len(sizey_new) > 0:
try:
sizex = int( sizex_new )
sizey = int( sizey_new )
except TypeError:
print "Screen size requires integers"
#now a reasonableness check
if sizex < 100: sizex = 100
if sizey < 100: sizey = 100
if sizey > xmax*2: sizex = xmax*2
if sizey > ymax*2: sizey = ymax*2
geometry = "%dx%d+%d+%d"%(sizex,sizey,startx,starty)
root.wm_geometry(geometry)
ent1.config(text=sizex); ent2.config(text=sizey)
root.update()
def quit():
root.destroy()
root.quit()
geometry = "%dx%d+%d+%d" % (sizex,sizey,startx,starty)
root.wm_geometry(geometry)
root.update()
myFont = ('Helvetica', 10, 'bold')
lab1 = Tkinter.Label(root,font=myFont,
text = "Screen size:\n%d wide x %d high\n" % (xmax, ymax))
lab1.grid(row=0, column=0, columnspan=1)
lab2 = Tkinter.Label(root,text = "Window size:\n")
lab2.grid(row=1, column=0, columnspan=1)
ent1 = Tkinter.Entry(root)
ent1.insert(0,sizex)
ent1.grid(row=2, column=0)
lab3 = Tkinter.Label(root, text = " X ")
lab3.grid(row=3, column=0)
ent2 = Tkinter.Entry(root )
ent2.insert(0, str(sizey) )
ent2.grid(row=4, column=0)
but1 = Tkinter.Button(root,text="Update",
command = lambda x=sizex,y=sizey: update(x,y) )
but1.grid(row=5, column=0, sticky="SW")
but2 = Tkinter.Button(root,text="Quit", command = quit)
but2.grid(row=5, column=0, stick= "S")
root.mainloop()
More information about the PythonCE
mailing list