Я хочу знать, как я могу вернуть значение из исполняемой программы, разработанной на python, значение, которое будет интерпретировано другим приложением.Также в зависимости от того, какая кнопка нажата, приложение python закрывается и возвращает определенное значение, которое будет использоваться в другом скрипте.Я пытался что-то, но я не знаю, что я делаю не так.Поместите какое-нибудь изображение с именем warning.jpg
в папку сценария, если вы хотите его запустить.
import wx
import gettext
import os
import time
global status
class MainFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self, parent, id, "===WARNING!===",size=(1000,700), style = wx.CAPTION )
self.Centre()
panel=wx.Panel(self)
self.statusbar = self.CreateStatusBar(1)
self.currentDirectory = os.getcwd()
print(self.currentDirectory)
warning = wx.StaticText (panel, -1, "Warning!!! Before you test, be sure you follow the instructions from the picture!", (150,5))
font = wx.Font(15, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
warning.SetFont(font)
try:
image_file = 'warning.jpg'
self.image = wx.Image(image_file,wx.BITMAP_TYPE_ANY).ConvertToBitmap()
self.bitmap_image = wx.StaticBitmap(self, -1, self.image, pos=(10,30), size=(700,350))
except:
wx.MessageBox("Verify that in path:"+self.currentDirectory+"\n"+"you have a picture named: \"warning\" of JPG OR BMP type")
quit()
self.DoneButton=wx.Button(panel,label='DONE!' ,pos=(150,500), size=(200,100))
self.DoneButton.SetBackgroundColour('green')
self.DoneButton.SetFont(wx.Font(15, wx.SWISS, wx.NORMAL, wx.BOLD))
self.Bind(wx.EVT_BUTTON, self.Done, self.DoneButton)
self.CancelButton=wx.Button(panel,label='CANCEL!' ,pos=(500,500), size=(200,100))
self.CancelButton.SetBackgroundColour('red')
self.CancelButton.SetFont(wx.Font(15, wx.SWISS, wx.NORMAL, wx.BOLD))
self.Bind(wx.EVT_BUTTON, self.Cancel, self.CancelButton)
def Done(self, event):
self.statusbar.PushStatusText('Done!!! Exiting...')
print("Done! Exiting...")
status = "ok"
return status
##also to kill the program after the button is pressed
def Cancel(self, event):
self.statusbar.PushStatusText('Exiting...')
print("Cancel! Exiting...")
status = "cancel"
return status
##also to kill the program after the button is pressed
if __name__ == "__main__":
gettext.install("app")
app = wx.App()
wx.InitAllImageHandlers()
frame_1 = MainFrame(None, wx.ID_ANY)
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()