Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import tkinter as tk
- import tkinter.messagebox as messagebox
- #############
- # paintman - sanitised code sample demonstrating bug.
- class MainWindow(tk.Frame):
- def __init__(self, master=None):
- super().__init__(master)
- master.title("Paintmgr") # References the Toplevel for the MainWindow
- self.master = master
- self.grid()
- self.create_widgets()
- def create_widgets(self):
- thiscol = 0
- tk.Label(self, text='Corner x').grid(row=0,column=thiscol)
- tk.Label(self, text='Corner y').grid(row=1,column=thiscol)
- tk.Label(self, text='Corner z').grid(row=2,column=thiscol)
- thiscol += 1
- self.xcoord = tk.Entry(self)
- self.xcoord.grid(row=0, column=thiscol)
- self.ycoord = tk.Entry(self)
- self.ycoord.grid(row=1, column=thiscol)
- self.zcoord = tk.Entry(self)
- self.zcoord.grid(row=2, column=thiscol)
- thiscol += 1
- tk.Button(self, text='Work on', command=self.WorkOnButtonAction).grid(row=0, column=thiscol)
- tk.Button(self, text='Quit', command=self.QuitButtonAction).grid( row=1, column=thiscol)
- for coliter in range(0,thiscol):
- self.columnconfigure(coliter, weight=1, pad=20)
- self.master.minsize(500,200)
- def QuitButtonAction(self):
- self.master.destroy()
- def WorkOnButtonAction(self):
- # Validate the original window's data before making a new window.
- # If the user gave invalid data, give a popup and stop.
- if not ( (self.xcoord.get().isdigit) and
- (self.ycoord.get().isdigit) and
- (self.zcoord.get().isdigit)):
- messagebox.showerror('Bad input', 'Input failed validation')
- return
- WorkOnWindow = tk.Toplevel()
- WorkOnWindow.title("Paimtmgr - Work")
- WorkOnWindow.grid()
- thiscol = 0
- tk.Label(WorkOnWindow, text=f'X:').grid(row=0, column=thiscol)
- tk.Label(WorkOnWindow, text=f'Y:').grid(row=1, column=thiscol)
- tk.Label(WorkOnWindow, text=f'Z:').grid(row=2, column=thiscol)
- tk.Label(WorkOnWindow, text=f'Status:').grid(row=3, column=thiscol)
- thiscol += 1
- tk.Button(WorkOnWindow, text='Fetch', command=self.FetchButtonAction).grid(row=0, column=thiscol)
- tk.Button(WorkOnWindow, text='Edit', command=self.EditButtonAction ).grid(row=1, column=thiscol)
- tk.Button(WorkOnWindow, text='Push', command=self.PushButtonAction ).grid(row=2, column=thiscol)
- thiscol += 1
- tk.Label(WorkOnWindow, text='Close this window when done with it.\nPlease do not edit settings in the main window while using this one.\nPlease do not open multiples of this window.').grid(row=4, column=0, columnspan=5)
- for coliter in range(0,thiscol):
- WorkOnWindow.columnconfigure(coliter, weight=1, pad=20)
- WorkOnWindow.minsize(500,200)
- def FetchButtonAction(self):
- pass
- def EditButtonAction(self):
- pass
- def PushButtonAction(self):
- pass
- root = tk.Tk()
- app = MainWindow(master=root)
- app.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement