Answers for "Tkinter framework"

6

how to create a tkinter window

#Creating Tkinter Window In Python:

from tkinter import *

new_window = Tk() #Create a window ; spaces should be denoted with underscores ; every window should have a different name
new_window.title("My Python Project") #Name of screen ; name should be the one which you already declared (new_window)
new_window.geometry("200x150") #Resizes the default window size
new_window.configure(bg = "red") #Gives color to the background

new_window.mainloop() #Shows the window on the screen
Posted by: Guest on November-07-2020
4

tkinter

from tkinter import * #import

def main():
  screen = Tk()#initialize
  screen.geomerty("num1xnum2") #pixels
  screen.title("Title")
  screen.cofigure(bg = 'grey')#hex colors or normal colors
  
  screen.mainloop()
main()#call
Posted by: Guest on June-28-2021
2

tkinter

from tkinter import *
from tkinter import ttk
root=Tk()
entry1=Entry(root,cursor="fleur",insertbackground="red")
entry1.pack()
Button(root,text="Get cursor type and colour", command=lambda: print(entry1['cursor'],entry1['insertbackground'])).pack()
root.mainloop()
Posted by: Guest on July-24-2021
0

gui in tkinter

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()
Posted by: Guest on November-29-2020
3

tkinter

from tkinter import * # import tkinter

window = Tk() #create a window

window.mainloop() #update window
Posted by: Guest on June-27-2021

Python Answers by Framework

Browse Popular Code Answers by Language