Answers for "tkinter python"

5

tkinter tutorial

# 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())
Posted by: Guest on November-22-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
5

basic tkinter gui

import tkinter as tk
root = tk.Tk()
root.title("my title")
root.geometry('200x150')
root.configure(background='black')

#	enter widgets here

root.mainloop()
Posted by: Guest on July-10-2020
2

functions calling upon creation tkinter fix

Make your event handler a lambda function, which calls your command() - in this case get_dir()
- with whatever arguments you want:

xbBrowse = Button(frameN, text="Browse...", font=fontReg, command=lambda : self.get_dir(xbPath))
Posted by: Guest on April-27-2020
1

python gui

# App python gui

import tkinter as tk
import webbrowser as wb


def Facebook():
    wb.open('facebook.com')


def Instagram():
    wb.open('instagram.com')


def Twitter():
    wb.open('twitter.com')


def Youtube():
    wb.open('youtube.com')


def Google():
    wb.open('google.com')


window = tk.Tk()
window.title('Browser')

google = tk.Button(window, text='Google', command=Google)
youtube = tk.Button(window, text='Youtube', bg='red', fg='white', command=Youtube)
twitter = tk.Button(window, text='Twitter', bg='powder blue', fg='white', command=Twitter)
Instagram = tk.Button(window, text='Instagram', bg='white', fg='black', command=Instagram)
facebook = tk.Button(window, text='Facebook', bg='blue', fg='white', command=Facebook)
facebook.pack()
Instagram.pack()
twitter.pack()
youtube.pack()
google.pack()

window.mainloop()
Posted by: Guest on November-07-2020
1

tkinter python

from tkinter import *
import time, datetime
from time import gmtime, strftime

root = Tk()

# Window Attributes
root.overrideredirect(1)
root.wm_attributes("-transparentcolor", "gray99")

running = True

# close window
def close(event):
    global running
    running = False

root.bind('<Escape>', close)

screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()

timeframe = Frame(root, width=screen_width, height=screen_height, bg="gray99")
timeframe.grid(row=0,column=0)

tkintertime = StringVar()
timelabel = Label(timeframe, textvariable=tkintertime, fg="white", bg="gray99", font=("NovaMono", 40))
timelabel.place(y=screen_height/2 - 60, x=screen_width/2, anchor="center")

tkinterdate = StringVar()
datelabel = Label(timeframe, textvariable=tkinterdate, fg="white", bg="gray99", font=("Bahnschrift", 15))
datelabel.place(y=screen_height/2 + 60, x=screen_width/2, anchor="center")


while running:
    tkintertime.set(value=strftime("%H:%M:%S"))
    tkinterdate.set(value=strftime("%A, %e %B"))
    root.update_idletasks()
    root.update()
    time.sleep(1)
Posted by: Guest on August-07-2021

Python Answers by Framework

Browse Popular Code Answers by Language