import tkinter import pyexcel_xls from infoWindow import InfoWindow from treeWindow import TreeWindow import os if __name__ == '__main__': win = tkinter.Tk() win.title('文学鉴赏') win.geometry('1280x720') #创建菜单栏 menubar = tkinter.Menu(win) win.configure(menu = menubar) #在菜单栏当中创建选项 menu1 = tkinter.Menu(menubar,tearoff = False) menu1.add_command(label='退出',command = win.quit) menubar.add_cascade(label='设置',menu = menu1) path = os.path.join(os.getcwd(),'poem.xls') # path = 'D:/python1801/Day19/1文学鉴赏上/poem.xls' dic_data = pyexcel_xls.get_data(path) #{'唐诗':[[1,'静夜思','李白','举头望明月,低头思故乡'],[1,'静夜思','李白','举头望明月,低头思故乡']......], # '宋词':[[],[],[]...],'元曲':[[],[],[]...]} infowin = InfoWindow(win) treewin = TreeWindow(win,dic_data,infowin) win.mainloop()调整代码让界面的字体大小为30
时间: 2023-12-03 09:04:17 浏览: 138
可以使用`font`属性来设置界面字体的大小。在代码中,可以将以下语句添加到`win`的初始化中,即可设置字体大小为30:
```python
win.option_add("*Font", "30")
```
修改后的完整代码如下:
```python
import tkinter
import pyexcel_xls
from infoWindow import InfoWindow
from treeWindow import TreeWindow
import os
if __name__ == '__main__':
win = tkinter.Tk()
win.title('文学鉴赏')
win.geometry('1280x720')
win.option_add("*Font", "30") # 设置字体大小为30
# 创建菜单栏
menubar = tkinter.Menu(win)
win.configure(menu=menubar)
# 在菜单栏当中创建选项
menu1 = tkinter.Menu(menubar, tearoff=False)
menu1.add_command(label='退出', command=win.quit)
menubar.add_cascade(label='设置', menu=menu1)
path = os.path.join(os.getcwd(), 'poem.xls')
# path = 'D:/python1801/Day19/1文学鉴赏上/poem.xls'
dic_data = pyexcel_xls.get_data(path)
infowin = InfoWindow(win)
treewin = TreeWindow(win, dic_data, infowin)
win.mainloop()
```
阅读全文