Python Forum
[Tkinter] newbie with python and tkinter
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] newbie with python and tkinter
#4
Hi pad

One way to start:
# -*- coding: utf-8 -*-

try:
    import Tkinter as tk
    import ttk
except ImportError:
    import tkinter as tk
    from tkinter import ttk

APP_TITLE = "My App"
APP_XPOS = 100
APP_YPOS = 100
APP_WIDTH = 300
APP_HEIGHT = 200

class Progress(object):

    def __init__(self, my_app):
        self.my_app = my_app

    def creat(self):
        print("create")
        
    def plus(self) :
        print("plus")
        
    def kill (self):
        print("kill")
        
class MyBeginnersApp(object):

    def __init__(self, app_win):
        self.app_win = app_win
        
        self.main_frame = tk.Frame(app_win)
        self.main_frame.pack(fill='both', expand=True, padx=10, pady=10)
        
        self.progress = Progress(self)
        
        self.build()
        
    def build(self):
        button_frame = tk.Frame(self.main_frame)
        button_frame.pack(expand=True, padx=4, pady=4)
        
        tk.Button(button_frame, text="run",
            command=self.progress.creat).pack(fill='x')
        tk.Button(button_frame, text="+++",
            command=self.progress.plus).pack(fill='x')
        tk.Button(button_frame, text="update",
            command=self.update).pack(fill='x')
        tk.Button(button_frame, text="kill",
            command=self.progress.kill).pack(fill='x')
        tk.Button(button_frame, text="Quit",
            command=quit).pack(fill='x')

    def update(self):
        print("update")
        
def main():
    app_win = tk.Tk()
    app_win.title(APP_TITLE)
    app_win.geometry("+{}+{}".format(APP_XPOS, APP_YPOS))
    #app_win.geometry("{}x{}".format(APP_WIDTH, APP_HEIGHT))
    
    app = MyBeginnersApp(app_win)
    
    app_win.mainloop()
 
 
if __name__ == '__main__':
    main()
wuf ;-)
Reply


Messages In This Thread
newbie with python and tkinter - by pat - Jun-26-2018, 07:50 AM
RE: newbie with python and tkinter - by wuf - Jun-26-2018, 01:57 PM
RE: newbie with python and tkinter - by pat - Jun-26-2018, 02:38 PM
RE: newbie with python and tkinter - by wuf - Jun-26-2018, 03:44 PM
RE: newbie with python and tkinter - by pat - Jun-26-2018, 05:53 PM
RE: newbie with python and tkinter - by wuf - Jun-26-2018, 06:31 PM
RE: newbie with python and tkinter - by pat - Jun-26-2018, 07:11 PM
RE: newbie with python and tkinter - by wuf - Jun-26-2018, 07:18 PM
RE: newbie with python and tkinter - by pat - Jun-26-2018, 07:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Python Newbie MartyH 6 2,814 May-13-2020, 07:07 PM
Last Post: MartyH
  Newbie question with Tkinter Entry mariolopes 2 2,303 Oct-12-2019, 11:02 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020