閲覧ありがとうございます。
メインプログラムの関数から別プログラムの関数を呼び出しているのですが、
別プログラムの関数が戻り値をうまく返してくれなくて困っています。
そこで別プログラムをsys.exit()で処理を終了させて呼び出し元のメイン関数に戻ろうとしているのですが、
そちらの方法もうまくいっていません。
何か別の方法もあれば教えていただきたいです。。。
よろしくお願いいたします。
Python
1def main():#メインプログラム 2 while True: 3 (省略) 4 if x == 0: 5 y = func() #別プログラム呼び出し 6 print(y) 7 if y == z: 8 break 9 continue 10 11 12 13 14 15if __name__ == '__main__': 16 main() 17
Python
1def Testfunc2(): #別プログラム 2 base01.withdraw() 3 base13 = tk.Tk() 4 base13.withdraw() 5 response = msg.showwarning('省略') 6 p = subprocess.Popen(['shutdown', '/i'], shell = True, stdout = subprocess.PIPE) 7 Pc = p.communicate() 8 print(Pc) 9 10 return Pc 11 12 13def func(): 14 15 base03 = tk.Tk() 16 base03.withdraw() 17 18 19 20 global base01 21 base01 = tk.Tk() 22 23 24 25 Shutdown_Option = {0:a, 1:b, 2:c} 26 27 button4 = tk.Button(base01, text=Shutdown_Option[0], command=Testfun1) 28 button5 = tk.Button(base01, text=Shutdown_Option[1], command=Testfunc2) 29 button5_1 = tk.Button(base01, text=Shutdown_Option[2], command=Testfun3) 30 31 32 button4.pack() 33 button5.pack() 34 button5_1.pack() 35 36 base01.mainloop() 37 38 39 40 41 42 43if __name__ == '__main__': 44 print(func())
回答2件
あなたの回答
tips
プレビュー