tkinter窗口在使用python3.3.3 32位时不会出现,但在64bi上运行良好

2024-10-03 06:29:19 发布

您现在位置:Python中文网/ 问答频道 /正文

如果我直接运行这个脚本(使用python命令),它可以在32位和64位python3.3.3安装中使用。 我的任务是集成企业版和扩展版。在

下面是我的源代码和错误截图。在

import win32com.client
import pythoncom
import ctypes
import sys
from tkinter import * 
import glob
import shutil
import sys
import os
from tkinter import filedialog

class Application():              
    def __init__(self, master=None):
            mGui =  Tk()
            mGui.geometry('400x80')
            mGui.title('Choose the template directory        ')
            mEntry = Entry(mGui,width=50,state="readonly",font=("Arial", 8,"bold")).grid(row=0,column=0,padx=(15),pady=(15))

            mButton = Button(mGui,text='Browse',font=("Arial", 8,"bold")).grid(row=0,column=1)
            mButton = Button(mGui,text='Save',font=("Arial", 8,"bold")).grid(row=1,column=0,padx=(15),pady=(2))           
            mGui.mainloop()

class EAAddin():
   _public_methods_ = ['EA_FileOpen', 'EA_GetMenuItems', 'EA_MenuClick']
   _reg_progid_ = "EAAddin"
   _reg_clsid_ = pythoncom.CreateGuid() 



   def EA_FileOpen(self, repo_obj):
    "Callback EA_FileOpen"
    repo = win32com.client.Dispatch(repo_obj)

    print("ConnectionString = ", repo.ConnectionString)

   def EA_GetMenuItems(self, repo_obj, menuLocation, menuName):
    "Callback EA_GetMenuItems"
    if menuName == "":        
        return "-EAAddin"
    else:
        menuOptions=[]
        menuOptions.append("Export")
        menuOptions.append("Templates Path")
        return menuOptions 



   def EA_MenuClick(self, repo_obj, menuLocation, menuName, itemName):
    "Callback EA_MenuClick" 
    app = Application()  
if __name__ == "__main__":

   print("Registering COM server...") 
   try:  
    import win32com.server.register
    win32com.server.register.UseCommandLine(EAAddin)
   except BaseException:
       print(BaseException)

64位版本的屏幕截图如下。 我点击加载项 enter image description here

结果-

enter image description here

32位版本的屏幕截图如下。 我点击加载项 enter image description here

结果-

enter image description here

如果有什么需要我做的,请告诉我。在


Tags: importselfobjdefrepogridwin32comrow