Python tkinter簡易廣告牌

2021-10-08 07:20:51 字數 2050 閱讀 7661

使用tkinter製作的簡易廣告牌,v1.0:

2020.07.19

功能:在視窗滾動顯示廣告.

import tkinter as tk

global advertise

advertise = ' 千里之行,始於足下 '

def show_ad():

global advertise

text1.delete(0.0,tk.end) #清除文字框內容

text1.insert(tk.insert,advertise)

text1.update()

advertise = advertise[1:]+advertise[0]

text1.after(500,show_ad) #實現文字框顯示重新整理

top = tk.tk() #建立視窗物件的背景色

text1 = tk.text(top) #建立文字

text1.pack() #將小部件放在主視窗中

show_ad()

top.mainloop() #進入訊息迴圈

使用tkinter製作的簡易廣告牌,v2.0:

2020.07.24

功能:使用者可以輸入廣告資訊,並滾動廣告標語

import tkinter as tk

class show_ad(tk.frame):

def __init__(self,parent=none,**kw):

tk.frame.__init__(self,parent,kw)

self.advertise = tk.strin**ar()

self.textentry = tk.strin**ar()

entry = tk.entry(frame1,textvariable=self.textentry)

self.textentry.set('請輸入廣告資訊')

entry.pack()

button = tk.button(frame1,text='確定',command=self.updatetext)

button.pack()

self.wintext()

def wintext(self):

lable = tk.label(self,textvariable=self.advertise)

lable.pack(side='bottom')

def setcontent(self):

self.advertise.set(self.content)

def updatetext(self):

self.content = self.textentry.get()

self.start()

def dataupdate(self):

self.content = self.content[1:]+self.content[0]

# print(self.content)

self.after(500,self.start)

def start(self):

self.setcontent()

self.dataupdate()

self.pack(side='bottom')

if __name__ == '__main__':

root = tk.tk() #建立視窗物件的背景色

root.title('廣告牌 演示')

Python Tkinter 布局方式

優點問題,如何在介面上顯示 定義 所有的tkinter 元件都包含專用的幾何管理方法,這些方法是用來組織和管理整個父配件區中子配件的布局的。tkinter 提供了截然不同的三種幾何管理類 pack grid 和place。pack 幾何管理採用塊的方式組織配件,在快速生成介面設計中廣泛採用,若干元件...

python tkinter 單選 多選

單選按鈕 tkinter.radiobutton root,text a pack tkinter.radiobutton root,text b pack tkinter.radiobutton root,text c pack 預設被選中,且單個一組 variable把radiobutton分成...

Python tkinter例項 簡單介紹

usr bin env python3.3 coding utf 8 import tkinter as tk from tkinter import ttk def sample1 hello title 1,最簡單 root tk.tk root.title 你好,這是tkinter世界 roo...