Example #1
0
    def __init__(self,
                 parent,
                 pos=(-.50, -.50),
                 size=(.50, .10),
                 anchor=constants.MID_CENTER,
                 **kwargs):
        kwargs.setdefault('wrap', False)
        kwargs.setdefault("shrink_factor", 1)
        kwargs.setdefault("text_size", 20)
        self.default_text = kwargs.pop("default_text", "")
        ok_type = kwargs.pop("ok_type", N_("&OK"))
        cancel_type = kwargs.pop("cancel_type", N_("&CANCEL"))
        super(TextEntryDialog, self).__init__(parent, pos, size, anchor,
                                              **kwargs)

        self.text_field = text.EditableText(self, (0, -.50), (-.71, -.50),
                                            borders=constants.ALL,
                                            base_font="normal")

        self.ok_button = button.FunctionButton(self, (-.72, -.50),
                                               (-.14, -.50),
                                               autotranslate=True,
                                               text=ok_type,
                                               function=self.return_text)
        self.cancel_button = button.FunctionButton(
            self, (-.86, -.50), (-.14, -.50),
            autotranslate=True,
            text=cancel_type,
            function=self.return_nothing)

        self.add_key_handler(pygame.K_RETURN, self.return_text)
        self.add_key_handler(pygame.K_KP_ENTER, self.return_text)
        self.add_key_handler(pygame.K_ESCAPE, self.return_nothing)
Example #2
0
    def __init__(self, parent, pos=(0, 0), size = (-1, -1),
                 anchor=constants.TOP_LEFT, *args, **kwargs):
        kwargs["yes_type"] = N_("&OK")
        kwargs["no_type"] = N_("&BACK")
        super(NewBaseDialog, self).__init__(parent, pos, size, anchor, *args,
                                            **kwargs)
        self.listbox.size = (-.53, -.75)
        self.description_pane.size = (-.45, -.75)

        self.text_label = text.Text(self, (.01, -.87), (-.25, -.1),
                                    autotranslate=True,
                                    text=N_("Name"),
                                    anchor=constants.BOTTOM_LEFT,
                                    borders=(constants.TOP, constants.BOTTOM, constants.LEFT),
                                    shrink_factor=.88,
                                    background_color="pane_background",
                                    )

        self.text_field = text.EditableText(self, (-.26, -.87), (-.73, -.1),
                                            anchor=constants.BOTTOM_LEFT,
                                            borders=constants.ALL,
                                            base_font="normal")

        self.desc_func = self.on_change

        self.yes_button.function = self.finish
Example #3
0
    def __init__(self, *args, **kwargs):
        super(VideoPane, self).__init__(*args, **kwargs)

        self.resolution_initialized = False

        self.resolution_label = text.Text(self, (.01, .01), (.14, .05),
                                          align=constants.LEFT,
                                          background_color="clear")

        self.resolution_choice = \
            listbox.UpdateListbox(self, (.16, .01), (.20, .25),
                                  update_func=self.update_resolution)

        self.resolution_custom = OptionButton(
            self, (.01, .28), (.14, .05),
            autohotkey=True,
            function=self.set_resolution_custom)

        self.resolution_custom_horiz = \
            text.EditableText(self, (.16, .28), (.14, .05),
                              text=str(gg.default_screen_size[0]),
                              borders=constants.ALL,
                              border_color="widget_border",
                              background_color=(0,0,50,255))

        self.resolution_custom_X = text.Text(self, (.30, .28), (.02, .05),
                                             text="X",
                                             base_font="special",
                                             background_color="clear")

        self.resolution_custom_vert = \
            text.EditableText(self, (.32, .28), (.14, .05),
                              text=str(gg.default_screen_size[1]),
                              borders=constants.ALL,
                              border_color="widget_border",
                              background_color=(0,0,50,255))

        self.fullscreen_label = button.HotkeyText(self, (.40, .01), (.30, .05),
                                                  autohotkey=True,
                                                  align=constants.LEFT,
                                                  background_color="clear")
        self.fullscreen_toggle = OptionButton(self, (.71, .01), (.07, .05),
                                              text_shrink_factor=.75,
                                              force_underline=-1,
                                              function=self.set_fullscreen,
                                              args=(button.TOGGLE_VALUE, ))
        self.fullscreen_label.hotkey_target = self.fullscreen_toggle

        self.daynight_label = button.HotkeyText(self, (.40, .08), (.30, .05),
                                                autohotkey=True,
                                                align=constants.LEFT,
                                                background_color="clear")
        self.daynight_toggle = OptionButton(self, (.71, .08), (.07, .05),
                                            text_shrink_factor=.75,
                                            force_underline=-1,
                                            function=self.set_daynight,
                                            args=(button.TOGGLE_VALUE, ))
        self.daynight_label.hotkey_target = self.daynight_toggle

        self.grab_label = button.HotkeyText(self, (.40, .15), (.30, .05),
                                            autohotkey=True,
                                            align=constants.LEFT,
                                            background_color="clear")
        self.grab_toggle = OptionButton(self, (.71, .15), (.07, .05),
                                        text_shrink_factor=.75,
                                        force_underline=-1,
                                        function=self.set_grab,
                                        args=(button.TOGGLE_VALUE, ))
        self.grab_label.hotkey_target = self.grab_toggle
Example #4
0
    def __init__(self, *args, **kwargs):
        super(VideoPane, self).__init__(*args, **kwargs)

        self.resolution_initialized = False

        self.resolution_label = text.Text(self, (.01, .01), (.14, .05),
                                          autotranslate=True,
                                          text=N_("Resolution:"),
                                          align=constants.LEFT,
                                          background_color="clear")

        self.resolution_choice = \
            listbox.UpdateListbox(self, (.16, .01), (.20, .25),
                                  update_func=self.update_resolution)

        self.resolution_custom = button.HotkeyText(self, (.01, .28), (.14, .05),
                                                   autotranslate=True,
                                                   text=N_("&Custom:"),
                                                   align=constants.LEFT,
                                                   background_color="clear")

        self.resolution_custom_horiz = \
            text.EditableText(self, (.16, .28), (.14, .05),
                              text=str(gg.default_screen_size[0]),
                              allowed_characters=constants.DIGIT_CHARS,
                              borders=constants.ALL)

        self.resolution_custom_X = text.Text(self,
                                             (.30, .28),
                                             (.02, .05),
                                             text="X",
                                             base_font="special",
                                             background_color="clear")

        self.resolution_custom_vert = \
            text.EditableText(self, (.32, .28), (.14, .05),
                              text=str(gg.default_screen_size[1]),
                              allowed_characters=constants.DIGIT_CHARS,
                              borders=constants.ALL)

        self.resolution_custom_ok = button.FunctionButton(self, (.47, .28), (.14, .05),
                                                          autotranslate=True,
                                                          autohotkey=False,
                                                          text=N_("OK"),
                                                          function=self.set_resolution_custom)
        self.resolution_custom.hotkey_target = self.resolution_custom_ok

        self.fullscreen_label = button.HotkeyText(self, (.40, .01), (.30, .05),
                                                  autotranslate=True,
                                                  text=N_("&Fullscreen:"),
                                                  align=constants.LEFT,
                                                  background_color="clear")
        self.fullscreen_toggle = OptionButton(self, (.715, .01), (.07, .05),
                                              autotranslate=True,
                                              autohotkey=False,
                                              text_shrink_factor=.75,
                                              force_underline=-1,
                                              function=self.set_fullscreen,
                                              args=(button.TOGGLE_VALUE,))
        self.fullscreen_label.hotkey_target = self.fullscreen_toggle

        self.daynight_label = button.HotkeyText(self, (.40, .08), (.30, .05),
                                                autotranslate=True,
                                                text=N_("Da&y/night display:"),
                                                align=constants.LEFT,
                                                background_color="clear")
        self.daynight_toggle = OptionButton(self, (.715, .08), (.07, .05),
                                            autotranslate=True,
                                            autohotkey=False,
                                            text_shrink_factor=.75,
                                            force_underline=-1,
                                            function=self.set_daynight,
                                            args=(button.TOGGLE_VALUE,))
        self.daynight_label.hotkey_target = self.daynight_toggle

        self.grab_label = button.HotkeyText(self, (.40, .15), (.30, .05),
                                            autotranslate=True,
                                            text=N_("&Mouse grab:"),
                                            align=constants.LEFT,
                                            background_color="clear")
        self.grab_toggle = OptionButton(self, (.715, .15), (.07, .05),
                                        autotranslate=True,
                                        autohotkey=False,
                                        text_shrink_factor=.75,
                                        force_underline=-1,
                                        function=self.set_grab,
                                        args=(button.TOGGLE_VALUE,))
        self.grab_label.hotkey_target = self.grab_toggle