草庐IT

tkinter.scrollbar

全部标签

python - 为什么在 Tkinter 中计算的字符串的宽度和高度(以像素为单位)因平台而异?

我有一个Python脚本,它需要计算以任意字体显示的任意字符串的确切大小,以便生成简单的图表。我可以用Tkinter轻松做到这一点。importTkinterastkimporttkFontroot=tk.Tk()canvas=tk.Canvas(root,width=300,height=200)canvas.pack()(x,y)=(5,5)text="yellowworld"fonts=[]for(family,size)in[("times",12),("times",24)]:font=tkFont.Font(family=family,size=size)(w,h)=(fo

python - 通过 ssh 使用 tkinter 没有显示名称和没有 $DISPLAY 环境变量

这个问题在这里已经有了答案:GeneratingaPNGwithmatplotlibwhenDISPLAYisundefined(13个回答)关闭8年前。我正在尝试运行一个在集群中输出.png文件的非常简单的代码。代码如下:importmatplotlib.pyplotaspltimportnumpyasnpx=np.random.randn(60)y=np.random.randn(60)plt.scatter(x,y,s=20)out_png='path/to/store/out_file.png'plt.savefig(out_png,dpi=150)如果我在安装了matplot

python - 通过 ssh 使用 tkinter 没有显示名称和没有 $DISPLAY 环境变量

这个问题在这里已经有了答案:GeneratingaPNGwithmatplotlibwhenDISPLAYisundefined(13个回答)关闭8年前。我正在尝试运行一个在集群中输出.png文件的非常简单的代码。代码如下:importmatplotlib.pyplotaspltimportnumpyasnpx=np.random.randn(60)y=np.random.randn(60)plt.scatter(x,y,s=20)out_png='path/to/store/out_file.png'plt.savefig(out_png,dpi=150)如果我在安装了matplot

python - 如何在 tkinter 中创建日期选择器?

tkinter应用程序是否有任何标准方式允许用户选择日期? 最佳答案 如果有人仍然需要这个-这是一个使用tkcalendar包创建日历和DateEntry小部件的简单代码。pipinstalltkcalendar(forinstallingthepackage)try:importtkinterastkfromtkinterimportttkexceptImportError:importTkinterastkimportttkfromtkcalendarimportCalendar,DateEntrydefexample1():d

python - 如何在 tkinter 中创建日期选择器?

tkinter应用程序是否有任何标准方式允许用户选择日期? 最佳答案 如果有人仍然需要这个-这是一个使用tkcalendar包创建日历和DateEntry小部件的简单代码。pipinstalltkcalendar(forinstallingthepackage)try:importtkinterastkfromtkinterimportttkexceptImportError:importTkinterastkimportttkfromtkcalendarimportCalendar,DateEntrydefexample1():d

python - 如何将回车键绑定(bind)到 tkinter 中的函数?

我是一名Python初学者,在MacOS上运行。我正在tkinter中使用文本解析器GUI制作程序,您可以在Entry中键入命令小部件,然后点击Button小部件,触发我的parse()函数等,将结果打印到Text小部件,文本冒险风格。>CircumventthebuttonIcan'tletyoudothat,Dave.我正试图找到一种方法来摆脱将鼠标拖到Button的需要。每次用户发出命令,但结果比我想象的要难。我猜正确的代码看起来像self.bind('',self.parse())?但我什至不知道该放在哪里。root,__init__,parse(),和create_widge

python - 如何将回车键绑定(bind)到 tkinter 中的函数?

我是一名Python初学者,在MacOS上运行。我正在tkinter中使用文本解析器GUI制作程序,您可以在Entry中键入命令小部件,然后点击Button小部件,触发我的parse()函数等,将结果打印到Text小部件,文本冒险风格。>CircumventthebuttonIcan'tletyoudothat,Dave.我正试图找到一种方法来摆脱将鼠标拖到Button的需要。每次用户发出命令,但结果比我想象的要难。我猜正确的代码看起来像self.bind('',self.parse())?但我什至不知道该放在哪里。root,__init__,parse(),和create_widge

python - 如何在 tkinter 中找出当前小部件的大小?

我正在使用Python和Tkinter,我需要知道小部件的当前尺寸(宽度、高度)。我试过somewidget["width"],但它只返回一个固定值,并且不会在小部件大小发生变化时更新(例如,当窗口大小调整时)。 最佳答案 somewidget.winfo_width()和somewidget.winfo_height()给出1.你需要更新Tk(发出tk.update())在获取这些值之前。 关于python-如何在tkinter中找出当前小部件的大小?,我们在StackOverflow

python - 如何在 tkinter 中找出当前小部件的大小?

我正在使用Python和Tkinter,我需要知道小部件的当前尺寸(宽度、高度)。我试过somewidget["width"],但它只返回一个固定值,并且不会在小部件大小发生变化时更新(例如,当窗口大小调整时)。 最佳答案 somewidget.winfo_width()和somewidget.winfo_height()给出1.你需要更新Tk(发出tk.update())在获取这些值之前。 关于python-如何在tkinter中找出当前小部件的大小?,我们在StackOverflow

python - Tkinter 和 Tix 的颜色图表

我想可视化一些基本颜色,以便为我的配色方案选择合适的颜色。我在任何地方都找不到颜色图表,因此修改了一个示例以显示它。这是一个好方法吗?importTixastk#importtkinter.tixastk#forPython3COLORS=['snow','ghostwhite','whitesmoke','gainsboro','floralwhite','oldlace','linen','antiquewhite','papayawhip','blanchedalmond','bisque','peachpuff','navajowhite','lemonchiffon','mi