将tk窗口移动到另一个监视器会导致python崩溃

时间:2017-12-10 20:59:36

标签: python python-3.x tkinter crash

我正在尝试为我的代码制作一个模拟Enigma的applet。当我运行代码时,窗口会弹出,一切都很好。我可以在我的笔记本电脑显示器上使用它,一切正常。当我将窗口移动到外部显示器(更高分辨率)并触摸其中一个组合框时,整个事情就会崩溃。我正在使用python和tkinter。

这里是代码:

import tkinter as tk
from tkinter import ttk

class EnigmaIApp(tk.Tk):

    def __init__(self, *args, **kwargs):

        tk.Tk.__init__(self, *args, **kwargs)

        tk.Tk.wm_title(self, "Enigma I")
        tk.Tk.wm_resizable(self,0,0)
        tk.Tk.grid_propagate(self,0)
        container = ttk.Frame(self, padding="3 3 12 12")

        container.pack(side="top", fill="both", expand = True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)


        self.frames = {}

        frame = Emulator(container, self)

        self.frames[Emulator] = frame

        frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame(Emulator)

    def show_frame(self, cont):

        frame = self.frames[cont]
        frame.tkraise()


class Emulator(ttk.Frame):

    def __init__(self, parent, controller):

        ttk.Frame.__init__(self, parent)
        self.columnconfigure(0, weight = 1)
        self.columnconfigure(1, weight = 1)
        self.columnconfigure(2, weight = 1)

        self.sl1, self.sl2, self.sl3 = tk.StringVar(), tk.StringVar(), tk.StringVar()

        Scrambler1_SL = ttk.Combobox(self, textvariable=self.sl1, width=10, values = ('I', 'II', 'III', 'IV', 'V'), state="readonly")
        Scrambler1_SL.grid(column=0, row=3, columnspan=12, sticky='w', padx='5')
        Scrambler1_SL.current(2)

        Scrambler2_SL = ttk.Combobox(self, textvariable=self.sl2, width=10, values = ('I', 'II', 'III', 'IV', 'V'), state="readonly")
        Scrambler2_SL.grid(column=1, row=3, columnspan=12, sticky='w', padx='5')
        Scrambler2_SL.current(3)

        Scrambler3_SL = ttk.Combobox(self, textvariable=self.sl3, width=10, values = ('I', 'II', 'III', 'IV', 'V'), state="readonly")
        Scrambler3_SL.grid(column=2, row=3, columnspan=12, sticky='w', padx='5')
        Scrambler3_SL.current(4)


app = EnigmaIApp()
app.geometry("500x100")
app.mainloop()

这是我通过终端

运行时收到的错误消息
2017-12-10 22:21:31.964 Python[49309:1734127] *** Assertion failure in -[_NSCGSWindow setFrame:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.10.101/CGS.subproj/NSCGSWindow.m:962
2017-12-10 22:21:31.971 Python[49309:1734127] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: CGRectContainsRect(CGRectMake((CGFloat)INT_MIN, (CGFloat)INT_MIN, (CGFloat)INT_MAX - (CGFloat)INT_MIN, (CGFloat)INT_MAX - (CGFloat)INT_MIN), frame)'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010010953b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x0000000100dd7942 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010010f122 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x0000000106c54690 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
    4   AppKit                              0x0000000104ab52a8 -[_NSCGSWindow setFrame:] + 475
    5   AppKit                              0x0000000104b6cd35 _NSCreateWindowWithOpaqueShape2 + 248
    6   AppKit                              0x0000000104b6b993 -[NSWindow _commonAwake] + 1057
    7   AppKit                              0x0000000105516fdc -[NSWindow(NSFullScreen) _resolveAutomaticEnterFullScreenFlags] + 51
    8   AppKit                              0x0000000104b6b41e -[NSWindow makeKeyAndOrderFront:] + 31
    9   Tk                                  0x0000000104803e94 XMapWindow + 165
    10  Tk                                  0x0000000104779302 Tk_MapWindow + 152
    11  Tk                                  0x000000010480b726 TkpWmSetState + 88
    12  Tk                                  0x000000010480967e TkMacOSXUnregisterMacWindow + 8494
    13  Tcl                                 0x0000000104671660 Tcl_ListMathFuncs + 1847
    14  Tcl                                 0x00000001046b0354 Tcl_ExprObj + 14350
    15  Tcl                                 0x00000001046e9e27 TclObjInterpProcCore + 632
    16  Tcl                                 0x0000000104671660 Tcl_ListMathFuncs + 1847
    17  Tcl                                 0x00000001046b0354 Tcl_ExprObj + 14350
    18  Tcl                                 0x00000001046e9e27 TclObjInterpProcCore + 632
    19  Tcl                                 0x0000000104671660 Tcl_ListMathFuncs + 1847
    20  Tcl                                 0x0000000104672873 Tcl_EvalEx + 2046
    21  Tcl                                 0x000000010467208f Tcl_EvalEx + 26
    22  Tk                                  0x0000000104754dea Tk_BindEvent + 3883
    23  Tk                                  0x0000000104759439 TkBindEventProc + 336
    24  Tk                                  0x000000010476045e Tk_HandleEvent + 1060
    25  Tk                                  0x00000001047609d8 Tk_QueueWindowEvent + 528
    26  Tcl                                 0x00000001046dc7af Tcl_ServiceEvent + 137
    27  Tcl                                 0x00000001046dca61 Tcl_DoOneEvent + 317
    28  _tkinter.cpython-36m-darwin.so      0x0000000104654aa1 _tkinter_tkapp_mainloop + 209
    29  Python                              0x00000001007b47b8 _PyCFunction_FastCallDict + 552
    30  Python                              0x000000010083e164 call_function + 612
    31  Python                              0x000000010083fb74 _PyEval_EvalFrameDefault + 5604
    32  Python                              0x000000010083d500 _PyEval_EvalCodeWithName + 2720
    33  Python                              0x000000010083dd2b fast_function + 219
    34  Python                              0x000000010083e14b call_function + 587
    35  Python                              0x000000010083fb74 _PyEval_EvalFrameDefault + 5604
    36  Python                              0x000000010083d500 _PyEval_EvalCodeWithName + 2720
    37  Python                              0x000000010083d6a4 PyEval_EvalCode + 100
    38  Python                              0x000000010087a00e PyRun_FileExFlags + 206
    39  Python                              0x000000010087a2af PyRun_SimpleFileExFlags + 447
    40  Python                              0x0000000100893b3a Py_Main + 3914
    41  Python                              0x0000000100000dfe Python + 3582
    42  Python                              0x0000000100000c34 Python + 3124
    43  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

0 个答案:

没有答案