Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7787223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:35:42+00:00 2026-06-01T20:35:42+00:00

So I can do a little C++ console stuff with classes (nothing too fancy

  • 0

So I can do a little C++ console stuff with classes (nothing too fancy I think) and just started with Python (awesome language, it’s like C++ without worries) and Tkinter.

The thing is that I don’t really have a clue how in general a program with a GUI is structured. I know you have to separate the interface from the internal workings, but that’s about it. As an example I am working on a small app that converts Excel tables to LaTeX tables and so far I have this:

from Tkinter import *

class ExcelToLateX:
    def __init__(self,master):
        self.convert = Button(master,text="Convert",command=self.Conversion)
        self.convert.pack(side=BOTTOM,fill=X)
        self.input=Input(master,40)
        self.output=Output(master,40)
    def Conversion(self):
        self.output.Write(self.input.Read())


class Input:
    def __init__(self,master,x):
        self.u=Text(master,width=x)
        self.u.pack(side=LEFT)
        self.u.insert(1.0,"Paste Excel data here...")

    def Read(self):
        return self.u.get(1.0,END)


class Output:
    def __init__(self,master,x):
        self.v=Text(master,width=x)
        self.v.pack(side=RIGHT)
        self.v.insert(1.0,"LaTeX code")
    def Write (self,input):
        self.input=input
        if self.v.get(1.0,END)=="":
            self.v.insert(1.0,self.input)
        else:
            self.v.delete(1.0,END)
            self.v.insert(1.0,self.input)

#Test script
root=Tk()
Window=ExcelToLateX(root)
root.mainloop()

So I have two Text widgets that can read and write stuff and a (for now) empty conversion class that will take Excel tables and spew out LaTeX code. I have no idea if this is the way to go (so any comments/tips are appreciated).

So in short I have two questions:

  • Are there any widely acknowledged sources that provide information on how a program with a GUI is structured? (preferably Python and Tkinter because that’s what I’m doing right know, although it may be a bit more general (cross-language))

  • Is my current application any good when it comes to structure, and if not, what are some rules of thumb and things I can improve?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:35:44+00:00Added an answer on June 1, 2026 at 8:35 pm

    I’m just going to throw a couple short comments into the hat. I don’t have experience with Tkinter, so my knowledge derives from PyQt4 experience.

    Right now you are using composition for your classes, by making the single widget a member attribute. This can obviously work but a useful pattern is to subclass a GUI widget, and then compose the layout by adding more child widgets and parenting to that class. See the examples on this random Tkinter tutorial link I found: http://zetcode.com/tutorials/tkintertutorial/

    class Example(Frame):
        def __init__(self, parent):
            super(Example, self).__init__(parent)
            ...
    

    And just as a general python convention, you should try and stick with capitalization for your class names, and camelCase or under_score for class instance methods and variables. As you have it, you are using capital for instances (Window =) and methods (Write)

    Also, if you aren’t going to be subclassing Tkinter widgets, make sure to at least use the new-style classes by subclassing from object: http://realmike.org/blog/2010/07/18/introduction-to-new-style-classes-in-python/

    You might also want to nest that last part of your code where you run the event loop inside of the classic python idiom:

    if __name__ == "__main__":
        root=Tk()
        window = ExcelToLateX(root)
        root.mainloop()
    

    It prevents your app from immediately being executed if you were to import this module into another application as a library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a little console application that uses s#arp. I can create an
I got a little problem, what I think, can't be hard. but somehow, I
I like to write a little server application being controlled by a little console
[update: by not using rake routes , just to understand Rails console a little
Html can contain little bits of Javascript embedded in it (e.g. defined in onclick
I am a little bit puzzled as to how I can optimize my program
I'm building a little search application (I know I can use match against). But
I'm developing a little portfolio where I can choose a category and when I
i got a got a little embedded system that can be controlled via a
I'm having a little trouble in understanding how I can read and return the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.