kassie
0
Q:

gui in tkinter

# check this code first.
from tkinter import *

app = Tk()
# The title of the project
app.title("The title of the project")
# The size of the window
app.geometry("400x400")

# Defining a funtion
def c():
    # Label
    m = Label(app, text="Text")
    m.pack()


# Button
l = Button(app, text="The text of the Butoon", command=c)
# Packing the Button
l.pack()
app.mainloop()
# Quick Note : 
# When you put a command you should not use parentheses
# l = Button(app, text="The text of the Butoon", command=c)
# l = Button(app, text="The text of the Butoon", command=c())
2
import tkinter as tk
root = tk.Tk()
root.title("my title")
root.geometry('200x150')
root.configure(background='black')

#	enter widgets here

root.mainloop()
5
# Python 3.x
import tkinter
top = tkinter.Tk()
# Code to add widgets will go here...
top.mainloop()

# I recommend creating each tkinter window as a child class to a frame.
# This keeps all methods related to the window encapsulated, and makes
# your code alot more understandable and readable :)
2
import tkinter as tk
#Importing the main module
window = tk.Tk()
window.mainloop()
1
from tkinter import *
import os

# window
window = Tk()
window.geometry("450x450")
window.title("Gui App")
window.configure(bg="powder blue")

# Enter or user input in tkinter
filename = Entry(window, width=75)
filename.pack()

# Run file Function

def runFile():
  try:
  	os.startfile(filename.get())
   
  except:
    error = Label(window, text=f"No file found as {filename.get}")
    error.pack()
    
 # Run file button
open_file_button = Button(window, text="Run File", command=runFile)
open_file_button.pack()

window.mainloop()
0

New to Communities?

Join the community