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");

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

    app = Application(root);
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

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