Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Instantiating a Frame object in Python 3's Tkinter GUI module

  1. Aug 4, 2012 #1
    Why is my code not working? It uses Python 3's tkinter module.
    There are no exception errors, it's just that the buttons don't show up on the GUI. It showed up when I created the Frame without using classes.

    from tkinter import*;

    root = Tk();
    root.title("Lazy Buttons");
    root.geometry("200x85");

    class Application(Frame):
    def __init__(self,master):
    Frame.__init__(self,master);
    self.grid;
    self.bttn_clicks = 0;
    self.create_widget();
    def create_widget(self):
    self.bttn = Button(self);
    self.bttn["text"] = "Total Clicks: 0";
    self.bttn["command"] = self.update_count;
    self.bttn.grid();
    def update_count(self):
    self.bttn_clicks += 1;
    self.bttn["text"] = "Total clicks: " + str(self.bttn_clicks);


    app = Application(root);
    root.mainloop();
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Instantiating a Frame object in Python 3's Tkinter GUI module
  1. Python 3 question (Replies: 4)

Loading...