| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 
 | import wx
 
class window(wx.Frame):
    def __init__(self,parent,id):
        # Init WX Frame
        wx.Frame.__init__(self,parent,id,'Converter', size=(400,200))
        # Define main panel
        self.panel=wx.Panel(self)
        # Define currencies array
        self.Currency=['USD','CAD','EUR']
        # Define 2 currencies list in the main panel
        self.List=wx.ListBox(self.panel, -1, (20,20), (100,100), self.Currency, wx.LB_SINGLE)
        self.List.SetSelection(0)
        self.Lists=wx.ListBox(self.panel, -1, (130,20), (100,100), self.Currency, wx.LB_SINGLE)
        self.Lists.SetSelection(1)
        # Some label
        wx.StaticText(self.panel, -1, "Your Currency", (40,5))
        wx.StaticText(self.panel, -1, "Convert to", (140,5))
        wx.StaticText(self.panel, -1, "Amount", (250,40))
        # Define the convert button
        self.convertbutton=wx.Button(self.panel,label="Convert",pos=(250,90),size=(60,30))
        # Set the action of the button
        self.Bind(wx.EVT_BUTTON, self.OnConvertClick, self.convertbutton)
        # Define the number input box
        self.spinner=wx.SpinCtrl(self.panel, -1, "", (250,60), (90,-1))
        self.spinner.SetRange(1,100)
        self.spinner.SetValue(1)
 
    def OnConvertClick(self, event):
        if self.Lists.Value==0 and self.List.Value==1:
            self.spinner.Value / 0.98
 
        self.spinner.GetValue()
 
if __name__=='__main__':
    app=wx.PySimpleApp()
    frame=window(parent=None,id=-1)
    frame.Show()
    app.MainLoop() | 
Partager