Python Forum
[Tkinter] Gui creation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Gui creation
#5
Hi Gangadhararao

Here my test script. It is absolutly not optimized. I just tried to interpret your script to create the following test script. I tested it with Ubuntu 18.04, Tkinter Tk8.6, Python 3.5. For images in the .jpg-format the PIL-Module is needed!:
import os
from functools import partial
import subprocess
import tkinter as tk

APP_TITLE = "Image Display"
APP_XPOS = 100
APP_YPOS = 100
APP_WIDTH = 350
APP_HEIGHT = 200


class Application(tk.Frame):

    def __init__(self, master):
        self.master = master
        tk.Frame.__init__(self, master)
        
        self.build()
         
    def build(self):

        # Heading
        self.heading = tk.Label(self, text="BBS", bg="black", fg="orange" ,
            font=("Times New Roman", 50))
        self.heading.pack() #place(x = 350, y = 0)

        self.label = tk.Label(self, text="MAIN MENU", bg="white", fg="orange",
            font=("Times New Roman", 50))
        self.label.pack()

        # Your image with path
        self.image = tk.PhotoImage(file=r"C:\ti\c2000\C2000Ware_1_00_04_00\utilities\flash_programmers\serial_flash_programmer\bbs.gif")
        # My test image
        #self.image = tk.PhotoImage(file="image.gif")
        self.image_width = self.image.width()
        self.image_height = self.image.height()

        self.canvas = tk.Canvas(self, width=self.image_width,
            height=self.image_height)
        self.canvas.pack()
        
        self.canvas.create_image(0, 0, anchor='nw', image=self.image)

        self.control_frame = tk.Frame(self)
        self.control_frame.pack()

        input_label = tk.Label(self.control_frame,
            text="Firmware Downloading to \n TMS320F2833x", bg="white",
            fg="blue" ,font=("Times New Roman", 20))
        input_label.grid(row=0, column=0)

        input_entry = tk.Entry(self.control_frame, bg="white", fg="green",
            font=("Times New Roman", 20))
        input_entry.grid(row=1, column=0)
        input_entry.focus_set()
        
        submit_button = tk.Button(self.control_frame, text = "Submit", bg="brown",
            fg="yellow", font=("Times New Roman", 20),
            command=partial(self.submit_callback , input_entry))
        submit_button.grid(row=2, column=0)

    def submit_callback(self, input_entry):
        print("User entered : " + input_entry.get())
        return
        cmd = subprocess.Popen("cmd.exe /K cd C:\\ti\\c2000\\C2000Ware_1_00_04_00\\utilities\\flash_programmers\\serial_flash_programmer & serial_flash_programmer.exe -d f2803x -k f28335_flash_kernel.txt -a PQCR.i00 -p COM7 -b 9600 -v")
        os.system("cd C:\\ti\\c2000\\C2000Ware_1_00_04_00\\utilities\\flash_programmers\\serial_flash_programmer")
        os.system("serial_flash_programmer.exe -d f2803x -k f28335_flash_kernel.txt -a PQCR.i00 -p COM3 -b 9600 -v & pause")

               
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 = Application(app_win)
    app.pack(fill='both', expand=True)
    
    app_win.mainloop()
 
 
if __name__ == '__main__':
    main()      
wuf ;-)
Reply


Messages In This Thread
Gui creation - by Gangadhararao - Jun-21-2018, 04:44 AM
RE: Gui creation - by Gangadhararao - Jun-21-2018, 07:37 AM
RE: Gui creation - by wuf - Jun-21-2018, 10:53 AM
RE: Gui creation - by Gangadhararao - Jun-21-2018, 02:50 PM
RE: Gui creation - by wuf - Jun-21-2018, 05:07 PM
RE: Gui creation - by Gangadhararao - Jun-26-2018, 04:02 AM
Command line with python - by Gangadhararao - Jun-26-2018, 05:21 AM
RE: Gui creation - by wuf - Jun-26-2018, 07:54 AM
RE: Gui creation - by wuf - Jun-26-2018, 10:35 AM
RE: Gui creation - by snippsat - Jun-27-2018, 06:29 PM

Forum Jump:

User Panel Messages

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