python-3.3

Tkinter - How to create submenus in menubar

我是研究僧i 提交于 2021-02-19 01:56:08
问题 Is it possible? By looking at the options I'm stumped. Searching on the web hasn't lead me anywhere. Can I create a submenu in the menubar. I'm referring to doing something similar to Idle Shell when I click on File and go down to Recent Files and it pulls up a separate file showing the recent files I've opened. If it's not possible what do I have to use to get it to work? 回答1: You do it exactly the way you add a menu to the menubar, with add_cascade . Here's an example: # Try to import

Tkinter - How to assign variable to currently selected item in Listbox?

霸气de小男生 提交于 2021-02-11 07:13:31
问题 I need help with a Python3.3 Tkinter scrollable list box that iterates through all the users installed fonts. The purpose of this function is to change the fonts in my Textfield in another part of my program.... from tkinter import * import tkinter.font def fontValue(): fontroot=Tk() fontroot.wm_title('FONTS') fonts=list(tkinter.font.families()) fonts.sort() fontbox = Listbox(fontroot,height=20) fontbox.pack(fill=BOTH, expand=YES, side=LEFT) scroll = Scrollbar(fontroot) scroll.pack(side=RIGHT

Tkinter - How to assign variable to currently selected item in Listbox?

霸气de小男生 提交于 2021-02-11 07:10:46
问题 I need help with a Python3.3 Tkinter scrollable list box that iterates through all the users installed fonts. The purpose of this function is to change the fonts in my Textfield in another part of my program.... from tkinter import * import tkinter.font def fontValue(): fontroot=Tk() fontroot.wm_title('FONTS') fonts=list(tkinter.font.families()) fonts.sort() fontbox = Listbox(fontroot,height=20) fontbox.pack(fill=BOTH, expand=YES, side=LEFT) scroll = Scrollbar(fontroot) scroll.pack(side=RIGHT

How to fix the order of dictionary handling in Python 3?

ぐ巨炮叔叔 提交于 2021-02-10 11:51:45
问题 Is there a way to reliably fix the order of dictionary handling in Python 3, i.e. establish iteration over keys and values with a predictable order? For debugging purposes and to reproduce a failure that, supposedly, is based on dictionary access in python 3.3 and 3.4, I need to somehow make the iteration over dictionaries predictable. What I mean is I want to fix the way any iteration is performed at the start of the Python program. Such that starting the program many times, calls to dict

ttk creating and using a custom theme

ⅰ亾dé卋堺 提交于 2021-02-07 09:48:58
问题 I am trying to incorporate a customizable theme choice in my program. I have been referring to this guide: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-themes.html, but I am lost. Here is a sample code I have been using to try to figure this out. I created a new theme, "Shadow," correctly, but the next part I'm struggling with. Let's just keep it simple and say within the "Shadow" theme I would like to change the frame background to black, the button background to navy and the button

python: Is there a downside to using faulthandler?

青春壹個敷衍的年華 提交于 2021-02-04 10:39:20
问题 Python 3.3 includes a module named faulthandler that displays helpful traceback information if a segfault occurs. (For Python versions prior to 3.3, the module can be obtained from PyPI.) The module is not enabled by default. It is enabled like this: import faulthandler faulthandler.enable() This feature is very useful. Is there any particular reason it isn't enabled by default? Does it have any negative effects on performance? 回答1: This feature is very useful. Is there any particular reason

Python 3.3: DeprecationWarning when using nose.tools.assert_equals

坚强是说给别人听的谎言 提交于 2021-01-27 13:26:31
问题 I am using nosetest tools for asserting a python unittest: ... from nose.tools import assert_equals, assert_almost_equal class TestPolycircles(unittest.TestCase): def setUp(self): self.latitude = 32.074322 self.longitude = 34.792081 self.radius_meters = 100 self.number_of_vertices = 36 self.vertices = polycircles.circle(latitude=self.latitude, longitude=self.longitude, radius=self.radius_meters, number_of_vertices=self.number_of_vertices) def test_number_of_vertices(self): """Asserts that the

Python 3.3: DeprecationWarning when using nose.tools.assert_equals

孤者浪人 提交于 2021-01-27 13:21:42
问题 I am using nosetest tools for asserting a python unittest: ... from nose.tools import assert_equals, assert_almost_equal class TestPolycircles(unittest.TestCase): def setUp(self): self.latitude = 32.074322 self.longitude = 34.792081 self.radius_meters = 100 self.number_of_vertices = 36 self.vertices = polycircles.circle(latitude=self.latitude, longitude=self.longitude, radius=self.radius_meters, number_of_vertices=self.number_of_vertices) def test_number_of_vertices(self): """Asserts that the

Coderunner uses old 2.71 version of Python instead of 3.2 on OSX 10.7.5

感情迁移 提交于 2020-12-25 03:50:32
问题 I am trying to use the newer version of Python but when I type: import sys print sys.version_info I get back: sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0) In the terminal when I type python I get: Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin When I type python3 I get: Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 13:52:24) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin As

Coderunner uses old 2.71 version of Python instead of 3.2 on OSX 10.7.5

孤街醉人 提交于 2020-12-25 03:50:11
问题 I am trying to use the newer version of Python but when I type: import sys print sys.version_info I get back: sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0) In the terminal when I type python I get: Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin When I type python3 I get: Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 13:52:24) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin As