Python获取屏幕分辨率大小
获取屏幕大小有两种方法可以办到:
1.wxpython里的
2.win32api
1 # coding:gb2312
2 # wxApp.py
3 # author: aoogur
4 import os
5 import wx
6 from win32api import GetSystemMetrics
7
8 class Frame(wx.Frame):
9 def __init__ (self):
10 wx.Frame.__init__(self,None,-1,title="wxApp.",size=(250,250),pos=(0,0))
11
12 #一种方法(wxPython)
13 mm=wx.DisplaySize()
14 print "width=",mm[0]
15 print 'height=',mm[1]
16 #另一种方法
17 print "width =", GetSystemMetrics (0)
18 print "height =",GetSystemMetrics (1)
19 class App(wx.App):
20 def OnInit(self):
21 frame = Frame()
22 frame.Show(True)
23 return True
24
25 if __name__ == "__main__":
26 app = App(False)
27 app.MainLoop()
2 # wxApp.py
3 # author: aoogur
4 import os
5 import wx
6 from win32api import GetSystemMetrics
7
8 class Frame(wx.Frame):
9 def __init__ (self):
10 wx.Frame.__init__(self,None,-1,title="wxApp.",size=(250,250),pos=(0,0))
11
12 #一种方法(wxPython)
13 mm=wx.DisplaySize()
14 print "width=",mm[0]
15 print 'height=',mm[1]
16 #另一种方法
17 print "width =", GetSystemMetrics (0)
18 print "height =",GetSystemMetrics (1)
19 class App(wx.App):
20 def OnInit(self):
21 frame = Frame()
22 frame.Show(True)
23 return True
24
25 if __name__ == "__main__":
26 app = App(False)
27 app.MainLoop()
相关文章