鱼C论坛

 找回密码
 立即注册
查看: 1773|回复: 5

[已解决]easygui的choicebox怎么改选择项

[复制链接]
发表于 2020-6-12 06:23:14 | 显示全部楼层 |阅读模式
2鱼币
2.7.JPG
最佳答案
2020-6-12 06:23:15
这个需要修改包了,需要修改python目录下Lib\site-packages\easygui\boxes中的choice_box.py,修改其中两个模块create_ok_button和create_cancel_button,修改前做好备份:
  1.     def create_ok_button(self):

  2.         self.buttonsFrame = tk.Frame(self.boxRoot)
  3.         self.buttonsFrame.pack(side=tk.TOP, expand=tk.YES, pady=0)

  4.         # put the buttons in the self.buttonsFrame
  5. #         okButton = tk.Button(self.buttonsFrame, takefocus=tk.YES,
  6. #                              text="OK", height=1, width=6)
  7.         okButton = tk.Button(self.buttonsFrame, takefocus=tk.YES,
  8.                              text="确认", height=1, width=6)                                #<----修改text改变按钮文字
  9.         bindArrows(okButton)
  10. #         okButton.pack(expand=tk.NO, side=tk.RIGHT, padx='2m', pady='1m',
  11. #                       ipady="1m", ipadx="2m")
  12.         okButton.pack(expand=tk.NO, side=tk.LEFT, padx='2m', pady='1m',       #<---修改side改变按钮位置
  13.                       ipady="1m", ipadx="2m")

  14.         # for the commandButton, bind activation events
  15.         okButton.bind("<Return>", self.ok_pressed)
  16.         okButton.bind("<Button-1>", self.ok_pressed)
  17.         okButton.bind("<space>", self.ok_pressed)

  18.     def create_cancel_button(self):
  19. #         cancelButton = tk.Button(self.buttonsFrame, takefocus=tk.YES,
  20. #                                  text="Cancel", height=1, width=6)
  21.         cancelButton = tk.Button(self.buttonsFrame, takefocus=tk.YES,
  22.                                  text="取消", height=1, width=6)                                #<----修改text改变按钮文字
  23.         bindArrows(cancelButton)
  24. #         cancelButton.pack(expand=tk.NO, side=tk.LEFT, padx='2m', pady='1m',
  25. #                           ipady="1m", ipadx="2m")
  26.         cancelButton.pack(expand=tk.NO, side=tk.RIGHT, padx='2m', pady='1m',      #<---修改side改变按钮位置
  27.                           ipady="1m", ipadx="2m")
  28.         cancelButton.bind("<Return>", self.cancel_pressed)
  29.         cancelButton.bind("<Button-1>", self.cancel_pressed)
  30.         # self.cancelButton.bind("<Escape>", self.cancel_pressed)
  31.         # for the commandButton, bind activation events to the activation event
  32.         # handler
复制代码

修改后的效果:
批注 2020-06-12 093438.png

最佳答案

查看完整内容

这个需要修改包了,需要修改python目录下Lib\site-packages\easygui\boxes中的choice_box.py,修改其中两个模块create_ok_button和create_cancel_button,修改前做好备份: 修改后的效果:
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-6-12 06:23:15 | 显示全部楼层    本楼为最佳答案   
这个需要修改包了,需要修改python目录下Lib\site-packages\easygui\boxes中的choice_box.py,修改其中两个模块create_ok_button和create_cancel_button,修改前做好备份:
  1.     def create_ok_button(self):

  2.         self.buttonsFrame = tk.Frame(self.boxRoot)
  3.         self.buttonsFrame.pack(side=tk.TOP, expand=tk.YES, pady=0)

  4.         # put the buttons in the self.buttonsFrame
  5. #         okButton = tk.Button(self.buttonsFrame, takefocus=tk.YES,
  6. #                              text="OK", height=1, width=6)
  7.         okButton = tk.Button(self.buttonsFrame, takefocus=tk.YES,
  8.                              text="确认", height=1, width=6)                                #<----修改text改变按钮文字
  9.         bindArrows(okButton)
  10. #         okButton.pack(expand=tk.NO, side=tk.RIGHT, padx='2m', pady='1m',
  11. #                       ipady="1m", ipadx="2m")
  12.         okButton.pack(expand=tk.NO, side=tk.LEFT, padx='2m', pady='1m',       #<---修改side改变按钮位置
  13.                       ipady="1m", ipadx="2m")

  14.         # for the commandButton, bind activation events
  15.         okButton.bind("<Return>", self.ok_pressed)
  16.         okButton.bind("<Button-1>", self.ok_pressed)
  17.         okButton.bind("<space>", self.ok_pressed)

  18.     def create_cancel_button(self):
  19. #         cancelButton = tk.Button(self.buttonsFrame, takefocus=tk.YES,
  20. #                                  text="Cancel", height=1, width=6)
  21.         cancelButton = tk.Button(self.buttonsFrame, takefocus=tk.YES,
  22.                                  text="取消", height=1, width=6)                                #<----修改text改变按钮文字
  23.         bindArrows(cancelButton)
  24. #         cancelButton.pack(expand=tk.NO, side=tk.LEFT, padx='2m', pady='1m',
  25. #                           ipady="1m", ipadx="2m")
  26.         cancelButton.pack(expand=tk.NO, side=tk.RIGHT, padx='2m', pady='1m',      #<---修改side改变按钮位置
  27.                           ipady="1m", ipadx="2m")
  28.         cancelButton.bind("<Return>", self.cancel_pressed)
  29.         cancelButton.bind("<Button-1>", self.cancel_pressed)
  30.         # self.cancelButton.bind("<Escape>", self.cancel_pressed)
  31.         # for the commandButton, bind activation events to the activation event
  32.         # handler
复制代码

修改后的效果:
批注 2020-06-12 093438.png
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-6-12 08:14:02 | 显示全部楼层

什么意思?是改动这两个按钮的位置嘛?

如果是的话不行了,最新版本的这两个按钮位置就是这样固定的,以前的是相反的
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-6-12 09:31:54 | 显示全部楼层
easygui如其名 很easy 一些想到的操作他也做不了 所以我选择Tkinter
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-6-12 20:07:10 | 显示全部楼层
沐羽尘 发表于 2020-6-12 09:31
easygui如其名 很easy 一些想到的操作他也做不了 所以我选择Tkinter

要改包唔唔唔
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-6-12 20:07:41 | 显示全部楼层
Twilight6 发表于 2020-6-12 08:14
什么意思?是改动这两个按钮的位置嘛?

如果是的话不行了,最新版本的这两个按钮位置就是这样固定的, ...

想改按钮的名字
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-21 18:15

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表