Exemple #1
0
    def __init__(self, login=None, password=None):
        wx.Frame.__init__(self, None, title='DTA4 Login')

        self.SetLabel('DTA4 Login')
        self.SetFont(the_font)
        self.SetBackgroundColour(dconfig.get('WINDOW_BG_COLOR'))
        self.SetForegroundColour(dconfig.get('WINDOW_FG_COLOR'))

        self.panel = wx.Panel(self)
        self.panel.SetForegroundColour(dconfig.get('WINDOW_FG_COLOR'))
        self.login_label = wx.StaticText(self.panel)
        self.password_label = wx.StaticText(self.panel)
        self.login_field = wx.TextCtrl(self.panel)
        self.password_field = wx.TextCtrl(self.panel, style=wx.TE_PASSWORD)
        self.okay_button = wx.Button(self.panel, label="Play")
        self.cancel_button = wx.Button(self.panel, label="Don't Play")

        self.sizer = wx.GridSizer(rows=3, cols=2,
                                    hgap=LOGIN_GRID_GAP,
                                    vgap=LOGIN_GRID_GAP)
        self.sizer.Add(self.login_label, 0, wx.EXPAND)
        self.sizer.Add(self.login_field, 0, wx.EXPAND)
        self.sizer.Add(self.password_label, 0, wx.EXPAND)
        self.sizer.Add(self.password_field, 0, wx.EXPAND)
        self.sizer.Add(self.okay_button, 0, wx.EXPAND)
        self.sizer.Add(self.cancel_button, 0, wx.EXPAND)

        self.over_sizer = wx.BoxSizer(wx.VERTICAL)
        self.over_sizer.Add(self.panel, 0, wx.EXPAND)

        self.login_label.SetLabel('Login:'******'Password:')
        if login is not None:
            self.login_field.SetValue(login)
        if password is not None:
            self.password_field.SetValue(password)

        self.okay_button.Bind(wx.EVT_BUTTON, self.login)
        self.cancel_button.Bind(wx.EVT_BUTTON, self.cancel)

        self.panel.SetSizer(self.sizer)
        self.panel.SetAutoLayout(1)
        self.sizer.Fit(self.panel)
        self.SetSizer(self.over_sizer)
        self.SetAutoLayout(1)
        self.over_sizer.Fit(self)
        self.Show()

        if login is not None:
            if password is not None:
                self.okay_button.SetFocus()
            else:
                self.password_field.SetFocus()
        else:
            self.login_field.SetFocus()
Exemple #2
0
 def login(self, evt):
     global the_error_frame
     uname = self.login_field.GetValue()
     paswd = self.password_field.GetValue()
     the_socket = dsock.LineSocket(dconfig.get('HOST'),
                                   dconfig.get('PORT'),
                                   dconfig.get('TIMEOUT'))
     the_socket.enque(dsock.comm_encode("LOGIN", uname))
     the_socket.enque(dsock.comm_encode("PASSWORD", paswd))
     the_socket.enque(dsock.comm_encode("VERSION", str(CLIENT_VERSION)))
     the_socket.send()
     typ, dat = the_socket.suck_read(wait=dconfig.get('TIMEOUT'), interval=0.2)
     if typ == "WELCOME":
         self.spawn_main_window(the_socket)
     elif typ == "TEXT":
         the_error_frame = ErrorWindow(dat, 'Error')
         self.Close()
     else:
         the_error_frame = ErrorWindow(
             "The server failed to respond appropriately.\n")
         self.Close()
Exemple #3
0
 def __init__(self, msg, title='Error'):
     wx.Frame.__init__(self, None, title=title)
     
     self.SetLabel(title)
     self.SetFont(the_font)
     self.SetBackgroundColour(dconfig.get('WINDOW_BG_COLOR'))
     self.SetForegroundColour(dconfig.get('WINDOW_FG_COLOR'))
     
     self.mesg = wx.StaticText(self)
     self.mesg.SetLabel(msg)
     self.bttn = wx.Button(self, label='k!')
     self.bttn.Bind(wx.EVT_BUTTON, self.dismiss)
     
     self.sizer = wx.BoxSizer(wx.VERTICAL)
     self.sizer.Add(self.mesg, 1, wx.EXPAND)
     self.sizer.Add(self.bttn, 0, wx.EXPAND)
     self.SetSizer(self.sizer)
     self.SetAutoLayout(1)
     self.sizer.Fit(self)
     self.Show()
     
     self.bttn.SetFocus()
Exemple #4
0
    def __init__(self, parent, title, the_socket):
        wx.Frame.__init__(self, parent, title=title, size=WINDOW_SIZE)

        self.SetLabel("DTA4")
        self.sock = the_socket

        self.current_cmd = ''
        self.cmd_history = []
        self.history_idx = 0

        self.read_queue_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.check_input_socket, self.read_queue_timer)
        self.read_queue_timer.Start(100)

        self.SetFont(the_font)
        self.default_attr = wx.TextAttr(dconfig.get('TEXT_FG_COLOR'),
                                        dconfig.get('TEXT_BG_COLOR'))
        if dconfig.get('COMMAND_ECHO_BG_COLOR') is not None:
            self.cmd_echo_attr = wx.TextAttr(
                                    dconfig.get('COMMAND_ECHO_FG_COLOR'),
                                    dconfig.get('COMMAND_ECHO_BG_COLOR'))
        else:
            self.cmd_echo_attr = wx.TextAttr(
                                    dconfig.get('COMMAND_ECHO_FG_COLOR'))

        self.SetBackgroundColour(dconfig.get('WINDOW_BG_COLOR'))
        self.SetForegroundColour(dconfig.get('WINDOW_FG_COLOR'))

        self.top_bar = wx.StaticText(self)
        self.bottom_bar = wx.StaticText(self)
        self.scrollback = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_RICH)
        self.input = wx.TextCtrl(self)

        self.scrollback.SetBackgroundColour(dconfig.get('TEXT_BG_COLOR'))
        self.scrollback.SetForegroundColour(dconfig.get('TEXT_FG_COLOR'))
        self.input.SetBackgroundColour(dconfig.get('INPUT_BG_COLOR'))
        self.input.SetForegroundColour(dconfig.get('INPUT_FG_COLOR'))

        self.scrollback.Bind(wx.EVT_CHAR, self.char_input)
        self.input.Bind(wx.EVT_CHAR, self.char_input)
        self.Bind(wx.EVT_CHAR, self.char_input)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.top_bar, 0, wx.EXPAND)
        self.sizer.Add(self.scrollback, 1, wx.EXPAND)
        self.sizer.Add(self.bottom_bar, 0, wx.EXPAND)
        self.sizer.Add(self.input, 0, wx.EXPAND)

        self.SetSizer(self.sizer)
        self.SetAutoLayout(1)
        self.Show()
        self.input.SetFocus()
Exemple #5
0
        the_error_frame = ErrorWindow(msg, 'Quitting')
        try:
            self.sock.close()
        except IOError:
            pass
        self.Close()
    
    def debug_msg(self, msg):
        if DEBUG is True:
            self.add_to_scrollback(msg, DEBUG_ATTR)

#####

dconfig.external_config(CONFIG_FILES)

if len(dconfig.get('WINDOW_SIZE')) != 2:
    sys.stderr.write('Bad window size in configuration file; using 640,480.\n')
    WINDOW_SIZE = (640, 480)
else:
    WINDOW_SIZE = dconfig.get('WINDOW_SIZE')
SCROLLBACK_SIZE = dconfig.get('SCROLLBACK_SIZE')

try:
    app = wx.App()
    the_font = wx.Font(
            family=wx.FONTFAMILY_TELETYPE,
            face=dconfig.get('FONT_FACE'),
            pointSize=dconfig.get('FONT_SIZE'),
            weight=wx.FONTWEIGHT_NORMAL,
            style=wx.FONTSTYLE_NORMAL)
    login_frame = LoginWindow(dconfig.get('LOGIN'), dconfig.get('PASSWORD'))