การใช้งาน Python GUI (Tkinter) : การเรียกใช้ Font

แชร์ความรู้ภาษา Python ไพทอน การเขียนโปรแกรมภาษาไพทอน

Moderators: mindphp, ผู้ดูแลกระดาน

User avatar
Jom07
PHP Super Hero Member
PHP Super Hero Member
Posts: 514
Joined: 08/01/2018 9:56 am

การใช้งาน Python GUI (Tkinter) : การเรียกใช้ Font

Post by Jom07 »

การใช้งาน Python GUI (Tkinter) : การเรียกใช้ Font เป็นการเลือกใช้ font ต่าง ๆ เช่น

Code: Select all

from Tkinter import *

root = Tk()

def window(main):
    main.title('Out Program')
    main.update_idletasks()
    width = 300
    height = 300
    x = (main.winfo_screenwidth() // 2)-(width // 2)
    y = (main.winfo_screenheight() // 2)-(height // 2)
    main.geometry('{}x{}+{}+{}'.format(width, height, x, y))

def main_content():
    hello = Label(root, text= 'MD Soft ', font='times 24')
    hello.pack()

window(root)
main_content()
mainloop()
Image

Code: Select all

from Tkinter import *

root = Tk()

def window(main):
    main.title('Out Program')
    main.update_idletasks()
    width = 300
    height = 300
    x = (main.winfo_screenwidth() // 2)-(width // 2)
    y = (main.winfo_screenheight() // 2)-(height // 2)
    main.geometry('{}x{}+{}+{}'.format(width, height, x, y))

def main_content():
    hello = Label(root, text= 'MD Soft ', font='times 24 bold')
    hello.pack()

window(root)
main_content()
mainloop()
Image

Code: Select all

from Tkinter import *

root = Tk()

def window(main):
    main.title('Out Program')
    main.update_idletasks()
    width = 300
    height = 300
    x = (main.winfo_screenwidth() // 2)-(width // 2)
    y = (main.winfo_screenheight() // 2)-(height // 2)
    main.geometry('{}x{}+{}+{}'.format(width, height, x, y))

def main_content():
    hello = Label(root, text= 'MD Soft ', font='times 24 bold italic')
    hello.pack()

window(root)
main_content()
mainloop()
Image

Code: Select all

from Tkinter import *

root = Tk()

def window(main):
    main.title('Out Program')
    main.update_idletasks()
    width = 300
    height = 300
    x = (main.winfo_screenwidth() // 2)-(width // 2)
    y = (main.winfo_screenheight() // 2)-(height // 2)
    main.geometry('{}x{}+{}+{}'.format(width, height, x, y))

def main_content():
    hello = Label(root, text= 'MD Soft ', font='times 24 bold italic underline')
    hello.pack()

window(root)
main_content()
mainloop()
Image

Code: Select all

from Tkinter import *

root = Tk()

def window(main):
    main.title('Out Program')
    main.update_idletasks()
    width = 300
    height = 300
    x = (main.winfo_screenwidth() // 2)-(width // 2)
    y = (main.winfo_screenheight() // 2)-(height // 2)
    main.geometry('{}x{}+{}+{}'.format(width, height, x, y))

def main_content():
    hello = Label(root, text= 'MD Soft ', font='times 24 bold italic underline', fg='#001dff', bg='#ffe500')
    hello.pack()

window(root)
main_content()
mainloop()
Image
Image
  • Similar Topics
    Replies
    Views
    Last post

Return to “Python Knowledge”

Who is online

Users browsing this forum: Google Adsense [Bot] and 25 guests