import tkinter as tk def create_window(): new_window = tk.Toplevel(root) new_window.title("New Window") root = tk.Tk() root.title("Main Window") button = tk.Button(root, text="Create New Window", command=create_window) button.pack() root.mainloop() 复制代码 在这个例子中,我们首先...
window_create (END, window=button) # 填充水平和垂直方向,这里设置 expand为 True 否则不能垂直方向延展 text .pack (fill=BOTH,expand=True) # 在第一行文字的第0个字符到第6个字符处插入标签,标签名称为"name" text.tag_add("name", "1.0", "1.6") # 将插入的按钮设置其标签名为"button" text.ta...
Fayson的github: https://github.com/fayson/cdhproject 提示:代码块部分可以左右滑动查看噢 1.文档编...
1fromtkinterimport*23root =Tk()4text = Text(root,width=20,height=15)5text.pack()6defshow():7text.insert(INSERT,"i love python")8print(text.get("1.2", 1.6))9b1 = Button(text,text="点我",command=show)10text.window_create(INSERT,window=b1) 执行结果: 2. “line.end” 行号加上字...
If you need to create additional windows, you can use theToplevelwidget. It simply creates a new window on the screen, a window that looks and behaves pretty much like the original root window: 如果需要创建额外的窗口,可以使用Toplevel组件。它简单的在屏幕上创建一个新的窗口,这个窗口的外观和行...
create_window 绘制窗口; delete 删除绘制的图形; itemconfig 修改图形属性,第一个参数为图形的ID,后边为想修改的参数; move 移动图像(1,4,0),1为图像对象,4为横移4像素,0为纵移像素,然后用root.update()刷新即可看到图像的移动,为了使多次移动变得可视,最好加上time.sleep()函数; ...
(file = "图片1.gif") self.w1.image_create(END,image = self.photo) def addWidget(self): b1 = Button(self.w1,text = "建国学堂") #在text创建组件的命令 self.w1.window_create(INSERT,window = b1) def testTag(self): self.w1.delete(1.0,END) self.w1.insert(INSERT,"good good study,...
import tkinter as tk def create_window(): window = tk.Toplevel(root) label = tk.Label(window, text="New Window") label.pack() root = tk.Tk() button = tk.Button(root, text="Create window", command=create_window) button.pack() root.mainloop() 15、为Canvas中(画布)的图形对象设置鼠标...
import tkinter as tk window = tk.Tk() window.title('创建窗口') window.geometry('300x200')...
(self.w1, text='Python')# 在text创建组件的命令self.w1.window_create(INSERT, window=b1)def testTag(self):self.w1.delete(1.0, END)self.w1.insert(INSERT, 'Good study Day Day up!\n黄河之水\n天上来\n奔流到海\n不复回\n百度一下')self.w1.tag_add('Good',1.0,1.4)self.w1.tag_config...