Now this class PhotoFrame could be used as many times as you'd like, although please understand you'll have to configure each frame appropriately, e.g. Now I tried not to give you the entire solution so you can learn and figure the rest out by yourself, but I'm sure you can see what I'm getting at in terms of using a class. Self.checkbox = tk.Checkbutton(self, variable=self.varc,
Self.title_id(row=0, column=0, columnspan=4, pady=5) Create the main window (container) Add any number of widgets to the main window.
To create a Tkinter : Importing the module tkinter. Creating a GUI using Tkinter is an easy task. Self.title_label = tk.Frame(self, text='Frame 3') # Or Frame 1, 2 etc. Python with Tkinter outputs the fastest and easiest way to create GUI applications. Tk.Frame._init_(self, master, bg='white', relief='ridge', bd=2) Here is how I might implement what you're trying to accomplish: import tkinter as tk Of course it is possible to create a class to represent similar objects. Value=mode, command = lambda:Rad_Val(v2)) P2 = Image.open(P2).resize((200, 200), Image.ANTIALIAS)ī = Radiobutton(Rad_Cont, text=text, variable=v2, id(row = 0, column = 0, columnspan = 4, pady = 5)Ĭheck_2 = Checkbutton(Photo_2, variable = varc2, text="Relevant?", command = lambda:Chk_Val(varc2))Ĭheck_2.grid(row = 1,column = 0,columnspan = 4) Photo_2 = Frame(master, bg = "white",relief = RIDGE, bd = 2) I do not want to have to repeat it 15 times.
#Easyframe or tkinter code#
I have included an example of the code I used to create one of the frames, this is the code that I want to make reusable. Then the next batch of photos is loaded and the process repeats. After all the photos have been classified by the user, a button is clicked that should then save all the photos with a new ID and also saves the info from the radio buttons into a csv file. I need to keep track of what the user does on each frame and save their selections on the radio buttons and check boxes for each frame. Its not very efficient to copy the code 15 times and I want to know if it's possible to use a class to define the frame once and reuse the code for each new frame. The radio buttons are there for the user to classify each photo, i.e front, back ,top etc. How would I create multiple frames that have the same widgets in Tkinter? Basically what I want to do is create 15 copies of a set of multiple frames that all contain the same widgets as shown in the image, the purpose of this program is to assist the user in sorting photographs into groups based on a specific ID supplied by the user.