2016-08-27 14 views
-1

メッセージボックスを表示したいのですが、Pythonで親ウィンドウを表示しません。これは私のコードです:Tkinterメッセージボックスの後ろにある画面を削除します

あなただけの唯一のダイアログボックスを表示するには、バックグラウンドで表示されている windowを削除する withdraw()機能を使用することができます
import Tkinter, tkFileDialog ,tkMessageBox 
from fileManagerModule import fileManager 
def load(): 
    global myFile,flag,msg 
    flag=True 
    options = {} 
    options["title"] = "choose a text File" 
    options['initialdir'] = '~/' 
    fileName = tkFileDialog.askopenfilename(**options) 
    myFile = fileManager(fileName) 
    myText.delete("1.0", Tkinter.END) 
    try: 
     line = myFile.readFromFile() 
     myText.insert("1.0", line) 
    except: 
     msg=Tkinter.Tk() 
     msg=tkMessageBox.showerror("Error","please choose file to load") 

screenshot

+0

あなたの全体のコードを共有してください:) –

+0

コードが大きすぎると私は詳細 –

+0

は、単に完全を作成し、_all_あなたのコードを表示しない必要はありません@NehalJWani 、実例。いくつかの行を追加するだけです(http://stackoverflow.com/help/mcve)。しかしまず、このサイトを検索し、いくつかのドキュメントを読んでみてください。この情報は多くの場所で利用可能です。 –

答えて

1

これを試してみてください。

import Tkinter, tkFileDialog ,tkMessageBox 
from fileManagerModule import fileManager 
def load(): 
    global myFile,flag,msg 
    flag=True 
    options = {} 
    options["title"] = "choose a text File" 
    options['initialdir'] = '~/'  
    fileName = tkFileDialog.askopenfilename(**options) 
    myFile = fileManager(fileName) 
    myText.delete("1.0", Tkinter.END) 
    try: 
     line = myFile.readFromFile() 
     myText.insert("1.0", line) 
    except: 
     msg=Tkinter.Tk() 

     msg.withdraw() 

     msg=tkMessageBox.showerror("Error","please choose file to load") 
関連する問題