I have a tkiner frame which holds a couple of buttons. I want to tie in one of these buttons to a pyautogui script, but the act of importing, but not implementing pyautogui, alters the size of all of my buttons, checkboxes and optionmenus. It happens in this window and all subwindows.
Why does this happen, and how can I keep my buttons the same size? the below code replicates the issue.
from tkinter import *
#import pyautogui # comment out to see normal sized
# buttons, include to see issue
class mywindow(Frame):
def __init__(self, master, *pargs):
Frame.__init__(self, master, *pargs)
master.overrideredirect(1)
self.frame = Frame(master, width=50, height=200,
borderwidth=2, relief=RAISED)
self.frame.grid(row=0,column=0)
self.bg = Label(self.frame, bg='gray30', width=50, height=200, anchor=E)
self.bg.pack()
self.mybutton1 = Button(self.bg, text="my text",
command=self.mycommand)
self.mybutton1.grid(row=0,sticky=W+E+N+S)
self.mybutton2 = Button(self.bg, text="my text",
command=self.mycommand)
self.mybutton2.grid(row=1,sticky=W+E+N+S)
self.mybutton3 = Button(self.bg, text="my text",
command=self.mycommand)
self.mybutton3.grid(row=2,sticky=W+E+N+S)
def mycommand(self):
pass
def center_window(root, width, height):
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x = (screen_width/2) - (width)
y = (screen_height/2) - (height)
root.geometry('%dx%d+%d+%d' % (width, height, x, y))
def go():
root = Tk()
center_window(root, 70, 110)
e = mywindow(root)
root.mainloop()
if __name__ == '__main__':
go()