appJar
只是一个包裹
tkinter
,您需要参考
root
/
master
的实例
Tk()
self.topLevel
在里面
gui
.
或者,你可以参考更漂亮的
self.appWindow
自己顶级
.
为了让所有事情都清楚,只需为继承类的所需方法添加一些“快捷方式”!
import appJar as aJ
class App(aJ.gui):
def __init__(self, *args, **kwargs):
aJ.gui.__init__(self, *args, **kwargs)
def winfo_screenheight(self):
# shortcut to height
# alternatively return self.topLevel.winfo_screenheight() since topLevel is Tk (root) instance!
return self.appWindow.winfo_screenheight()
def winfo_screenwidth(self):
# shortcut to width
# alternatively return self.topLevel.winfo_screenwidth() since topLevel is Tk (root) instance!
return self.appWindow.winfo_screenwidth()
app = App('winfo')
height, width = app.winfo_screenheight(), app.winfo_screenwidth()
app.setGeometry(int(width / 2), int(height / 2))
app.addLabel('winfo_height', 'height: %d' % height, 0, 0)
app.addLabel('winfo_width', 'width: %d' % width, 1, 0)
app.go()