Пример #1
0
    def addWidget(self, widget):
        """
        Adds a widget to the menu
        @param widget: The widget that should be added to the menu
        """
        widget_width = 128
        widget_height = 32
        widget_space = 2

        #(re-)calcluate rectangle size
        for i in range(0, len(self.widgets)):
            #print 'option_width: ' + str(option_width)
            #print "width of rectange [" + str(i) + "] = " + str(self.options[i].rect.width)
            if(widget_width < self.widgets[i].rect.width):
                widget_width = self.widgets[i].rect.width
            if(widget_height < self.widgets[i].rect.height):
                widget_height = self.widgets[i].rect.height

        widget.rect.width = widget_width
        widget.rect.height = widget_height
        widget.rect.centerx = (self.rect.width / 2)

        Frame.addWidget(self, widget)

        menu_height = widget_height * len(self.widgets)

        for i in range(0, len(self.widgets)):
            screen_center = self.rect.height / 2
            menu_top = (screen_center - (menu_height / 2))
            option_y = ((widget_height + widget_space) * i)
            self.widgets[i].rect.width = widget_width
            self.widgets[i].rect.height = widget_height
            self.widgets[i].rect.top = menu_top + option_y
Пример #2
0
def createApp():
  window = tkinter.Tk()
  setAppProperties(window)

  global left_frame, right_frame, search, list
  set_theme("dark")
  left_frame = Frame(window, dict(bg=GUI["colors"]["primary"], width=300, height=GUI["dimensions"]["height"]), "left", "y")
  right_frame = Frame(window, dict(bg=GUI["colors"]["secondary"], width=GUI["dimensions"]["width"] - 300, height=GUI["dimensions"]["height"]), "right", "y")
  search = Search(left_frame, "Search", dict(width = 20, font=('Inter', 12)), dict(x=10, y=10), dict(x=219, y=10), function = searchPassword)
  list = List(left_frame, getPasswords(), dict(fg="#ffffff", bg="#1c1c1c", highlightbackground='white', width = 25, height = 22, font=('Inter 15')), dict(x=10, y=50))
  list.bind("<<ListboxSelect>>", select)

  showPasswordInformation()
  window.mainloop()
Пример #3
0
    def __init__(self, nextScene, teamColor):
        """
        @param nextScene: The scene which should come after this win screen
        @param teamColor: The color of the winning team
        @summary: Initializes win screen for the winning team
        """
        Scene.__init__(self)
        self.nextScene = nextScene
        self.frame = Frame()
        text = "!!! Congratulations !!!\n"
        text += "\n"
        text += "The " + teamColor + " team has won"
        labelText = Label(text)
        labelText.rect.center = (self.frame.rect.width / 2, self.frame.rect.height / 2)

        buttonBack = Button("Back", self.runNextScene)
        buttonBack.rect.size = (128, 32)
        buttonBack.rect.centerx = self.frame.rect.width / 2
        buttonBack.rect.bottom = self.frame.rect.height - 32

        self.frame.addWidget(labelText)
        self.frame.addWidget(buttonBack)

        self.victory_sound = load_sound("victory.ogg")
        self.victory_sound.play()
Пример #4
0
def main():
    ball_speed = 3
    paddle_speed = 5
    #Starting pygame
    pygame.init()
    #Setting screen
    size = width, height = 1360, 768
    screen = pygame.display.set_mode(size)
    #Making the frame
    frame = Frame(dimensions=size)
    #Making the left paddle and setting its speed
    lpad = Paddle(pos=[0, height // 2],
                  up=pygame.K_w,
                  dwn=pygame.K_s,
                  speed=paddle_speed)
    #Making the right paddle and setting its speed
    rpad = Paddle(pos=[width - 20, height // 2], speed=paddle_speed)
    #Making the ball and setting its speed
    ball = Ball(pos=[width // 2, height // 2], speed=[ball_speed, ball_speed])
    #Making the scoreboard
    scoreboard = Scoreboard((0, 0), pos=[width // 2, 0])
    #Starting game loop
    game_loop(screen, frame, lpad, rpad, ball, scoreboard)
    #Quitting the game
    pygame.quit()
Пример #5
0
    def __init__(self, previousScene):
        """
        @param previousScene: The scene which should come after this help
        @summary: Initializes a help frame
        """
        Scene.__init__(self)
        self.previousScene = previousScene
        self.frame = Frame()
        text  = "Welcome to gravity snails\n"
        text += "=========================\n"
        text += "\n"
        text += "You can shoot the snails and the terrain beneath them\n"
        text += "Snails die if they touch the salt\nor when they are out of hitpoints\n"
        text += "\nCONTROLS\n=========================\n\n"
        text += "LEFT MOUSE BUTTON:\nplace snails in the screen\n\n"
        text += "ARROW KEYS:\nmove and target\n\n"
        text += "SPACE BAR:\nfire the active weapon\n\n"
        text += "RIGHT MOUSE BUTTON:\nswitch weapon\n\n"
        text += "\n"
        labelText = Label(text)
        labelText.centerLines = False
        labelText.rect.center = (self.frame.rect.width / 2, self.frame.rect.height / 2)
        self.frame.addWidget(labelText)

        buttonBack = Button("Back", self.runPreviousScene)
        buttonBack.rect.size = (128, 32)
        buttonBack.rect.centerx = self.frame.rect.width / 2
        buttonBack.rect.bottom = self.frame.rect.height - 32
        self.frame.addWidget(buttonBack)
Пример #6
0
    def Startup(self):
        # Importing takes sometime, therefore it will be done
        # while splash is being shown
        from gui.frame import Frame
        from control import Controller
        from project import Project

        self.main = Frame(None)
        self.control = Controller(self.main)

        self.fc = wx.FutureCall(1, self.ShowMain)
        wx.FutureCall(1, parse_comand_line)

        # Check for updates
        from threading import Thread
        p = Thread(target=utils.UpdateCheck, args=())
        p.start()
Пример #7
0
class HelpMenu(Scene):
    """
    @ivar previousScene: The scene which should come after this help
    """
    def __init__(self, previousScene):
        """
        @param previousScene: The scene which should come after this help
        @summary: Initializes a help frame
        """
        Scene.__init__(self)
        self.previousScene = previousScene
        self.frame = Frame()
        text  = "Welcome to gravity snails\n"
        text += "=========================\n"
        text += "\n"
        text += "You can shoot the snails and the terrain beneath them\n"
        text += "Snails die if they touch the salt\nor when they are out of hitpoints\n"
        text += "\nCONTROLS\n=========================\n\n"
        text += "LEFT MOUSE BUTTON:\nplace snails in the screen\n\n"
        text += "ARROW KEYS:\nmove and target\n\n"
        text += "SPACE BAR:\nfire the active weapon\n\n"
        text += "RIGHT MOUSE BUTTON:\nswitch weapon\n\n"
        text += "\n"
        labelText = Label(text)
        labelText.centerLines = False
        labelText.rect.center = (self.frame.rect.width / 2, self.frame.rect.height / 2)
        self.frame.addWidget(labelText)

        buttonBack = Button("Back", self.runPreviousScene)
        buttonBack.rect.size = (128, 32)
        buttonBack.rect.centerx = self.frame.rect.width / 2
        buttonBack.rect.bottom = self.frame.rect.height - 32
        self.frame.addWidget(buttonBack)

    def update(self, input):
        """
        @param input: The user input
        @summary: updates the status of the help frame based on the user input
        """
        self.frame.update(input)

    def draw(self, surface):
        """
        @param surface: The surface which the help should be drawed on
        @summary: draws the help frame on a specified surface
        """
        self.frame.draw(surface)

    def runPreviousScene(self):
        """
        @summary: closes the help frame and tells sceneManager to go to previous scene
        """
        SceneManager().setScene(self.previousScene)
Пример #8
0
class WinScreen(Scene):
    """
    @ivar nextScene: The scene which should come after this screen
    """
    def __init__(self, nextScene, teamColor):
        """
        @param nextScene: The scene which should come after this win screen
        @param teamColor: The color of the winning team
        @summary: Initializes win screen for the winning team
        """
        Scene.__init__(self)
        self.nextScene = nextScene
        self.frame = Frame()
        text = "!!! Congratulations !!!\n"
        text += "\n"
        text += "The " + teamColor + " team has won"
        labelText = Label(text)
        labelText.rect.center = (self.frame.rect.width / 2, self.frame.rect.height / 2)

        buttonBack = Button("Back", self.runNextScene)
        buttonBack.rect.size = (128, 32)
        buttonBack.rect.centerx = self.frame.rect.width / 2
        buttonBack.rect.bottom = self.frame.rect.height - 32

        self.frame.addWidget(labelText)
        self.frame.addWidget(buttonBack)

        self.victory_sound = load_sound("victory.ogg")
        self.victory_sound.play()

    def draw(self, surface):
        """
        @param surface: The surface which the win screen should be drawed on
        @summary: draws the win screen on a specified surface
        """
        self.frame.draw(surface)

    def update(self, input):
        """
        @param input: The user input
        @summary: updates the status of the win screen based on the user input
        """
        self.frame.update(input)

    def runNextScene(self):
        """
        @summary: closes the help frame and tells sceneManager to go to next scene
        """
        self.victory_sound.stop()
        SceneManager().setScene(self.nextScene)
Пример #9
0
 def __init__(self):
     """
     Initializes a menu
     """
     Frame.__init__(self)
Пример #10
0
class SplashScreen(wx.SplashScreen):
    """
    Splash screen to be shown in InVesalius initialization.
    """
    def __init__(self):
        # Splash screen image will depend on currently language
        lang = False

        # Language information is available in session configuration
        # file. First we need to check if this file exist, if now, it
        # should be created
        create_session = False
        session = ses.Session()
        if not (session.ReadSession()):
            create_session = True

        install_lang = 0
        # Check if there is a language set (if session file exists
        if session.ReadLanguage():
            lang = session.GetLanguage()
            if (lang != "False"):
                _ = i18n.InstallLanguage(lang)
                install_lang = 1
            else:
                install_lang = 0
        else:
            install_lang = 0

        # If no language is set into session file, show dialog so
        # user can select language
        if install_lang == 0:
            dialog = lang_dlg.LanguageDialog()

            # FIXME: This works ok in linux2, darwin and win32,
            # except on win64, due to wxWidgets bug
            try:
                ok = (dialog.ShowModal() == wx.ID_OK)
            except wx._core.PyAssertionError:
                ok = True
            finally:
                if ok:
                    lang = dialog.GetSelectedLanguage()
                    session.SetLanguage(lang)
                    _ = i18n.InstallLanguage(lang)
                else:
                    homedir = self.homedir = os.path.expanduser('~')
                    invdir = os.path.join(homedir, ".invesalius")
                    shutil.rmtree(invdir)
                    sys.exit()

        # Session file should be created... So we set the recent
        # choosen language
        if (create_session):
            session.CreateItens()
            session.SetLanguage(lang)
            session.WriteSessionFile()

        session.SaveConfigFileBackup()

        # Only after language was defined, splash screen will be
        # shown
        if lang:
            # For pt_BR, splash_pt.png should be used
            if (lang.startswith('pt')):
                icon_file = "splash_pt.png"
            else:
                icon_file = "splash_" + lang + ".png"

            path = os.path.join("..", "icons", icon_file)

            if not os.path.exists(path):
                path = os.path.join("..", "icons", "splash_en.png")

            bmp = wx.Image(path).ConvertToBitmap()

            style = wx.SPLASH_TIMEOUT | wx.SPLASH_CENTRE_ON_SCREEN
            wx.SplashScreen.__init__(self,
                                     bitmap=bmp,
                                     splashStyle=style,
                                     milliseconds=1500,
                                     id=-1,
                                     parent=None)
            self.Bind(wx.EVT_CLOSE, self.OnClose)
            wx.Yield()
            wx.CallLater(200, self.Startup)

    def Startup(self):
        # Importing takes sometime, therefore it will be done
        # while splash is being shown
        from gui.frame import Frame
        from control import Controller
        from project import Project

        self.main = Frame(None)
        self.control = Controller(self.main)

        self.fc = wx.FutureCall(1, self.ShowMain)
        wx.FutureCall(1, parse_comand_line)

        # Check for updates
        from threading import Thread
        p = Thread(target=utils.UpdateCheck, args=())
        p.start()

    def OnClose(self, evt):
        # Make sure the default handler runs too so this window gets
        # destroyed
        evt.Skip()
        self.Hide()

        # If the timer is still running then go ahead and show the
        # main frame now
        if self.fc.IsRunning():
            self.fc.Stop()
            self.ShowMain()

    def ShowMain(self):
        # Show main frame
        self.main.Show()

        if self.fc.IsRunning():
            self.Raise()
Пример #11
0
    def __init__(self, simulator):
        # bind the simulator
        self.simulator = simulator

        # initialize frame
        self.current_frame = Frame()

        # initialize camera parameters
        self.view_width_pixels = DEFAULT_VIEW_PIX_W
        self.view_height_pixels = DEFAULT_VIEW_PIX_H
        self.pixels_per_meter = DEFAULT_ZOOM

        # initialize the window
        self.window = Gtk.Window()
        self.window.set_title('Sobot Rimulator')
        self.window.set_resizable(False)
        self.window.connect('delete_event', self.on_delete)

        # initialize the drawing_area
        self.drawing_area = Gtk.DrawingArea()
        self.drawing_area.set_size_request(self.view_width_pixels,
                                           self.view_height_pixels)
        self.drawing_area.connect('draw', self.on_expose)

        # initialize the painter
        self.painter = Painter(self.pixels_per_meter)

        # == initialize the buttons

        # build the play button
        self.button_play = Gtk.Button('Play')
        play_image = Gtk.Image()
        play_image.set_from_stock(Gtk.STOCK_MEDIA_PLAY, Gtk.IconSize.BUTTON)
        self.button_play.set_image(play_image)
        self.button_play.set_image_position(Gtk.PositionType.LEFT)
        self.button_play.connect('clicked', self.on_play)

        # build the stop button
        self.button_stop = Gtk.Button('Stop')
        stop_image = Gtk.Image()
        stop_image.set_from_stock(Gtk.STOCK_MEDIA_STOP, Gtk.IconSize.BUTTON)
        self.button_stop.set_image(stop_image)
        self.button_stop.set_image_position(Gtk.PositionType.LEFT)
        self.button_stop.connect('clicked', self.on_stop)

        # build the step button
        self.button_step = Gtk.Button('Step')
        step_image = Gtk.Image()
        step_image.set_from_stock(Gtk.STOCK_MEDIA_NEXT, Gtk.IconSize.BUTTON)
        self.button_step.set_image(step_image)
        self.button_step.set_image_position(Gtk.PositionType.LEFT)
        self.button_step.connect('clicked', self.on_step)

        # build the reset button
        self.button_reset = Gtk.Button('Reset')
        reset_image = Gtk.Image()
        reset_image.set_from_stock(Gtk.STOCK_MEDIA_REWIND, Gtk.IconSize.BUTTON)
        self.button_reset.set_image(reset_image)
        self.button_reset.set_image_position(Gtk.PositionType.LEFT)
        self.button_reset.connect('clicked', self.on_reset)

        # build the save map button
        self.button_save_map = Gtk.Button('Save Map')
        save_map_image = Gtk.Image()
        save_map_image.set_from_stock(Gtk.STOCK_SAVE, Gtk.IconSize.BUTTON)
        self.button_save_map.set_image(save_map_image)
        self.button_save_map.set_image_position(Gtk.PositionType.LEFT)
        self.button_save_map.connect('clicked', self.on_save_map)

        # build the load map button
        self.button_load_map = Gtk.Button('Load Map')
        load_map_image = Gtk.Image()
        load_map_image.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.BUTTON)
        self.button_load_map.set_image(load_map_image)
        self.button_load_map.set_image_position(Gtk.PositionType.LEFT)
        self.button_load_map.connect('clicked', self.on_load_map)

        # build the random map buttons
        self.button_random_map = Gtk.Button('Random Map')
        random_map_image = Gtk.Image()
        random_map_image.set_from_stock(Gtk.STOCK_REFRESH, Gtk.IconSize.BUTTON)
        self.button_random_map.set_image(random_map_image)
        self.button_random_map.set_image_position(Gtk.PositionType.LEFT)
        self.button_random_map.connect('clicked', self.on_random_map)

        # build the show-invisibles toggle button
        self.show_invisibles = False  # controls whether invisible world elements are displayed
        self.button_show_invisibles = Gtk.Button()
        self._decorate_show_invisibles_button_inactive()
        self.button_show_invisibles.set_image_position(Gtk.PositionType.LEFT)
        self.button_show_invisibles.connect('clicked', self.on_show_invisibles)

        # == lay out the window

        # pack the simulation control buttons
        sim_controls_box = Gtk.HBox(spacing=5)
        sim_controls_box.pack_start(self.button_play, False, False, 0)
        sim_controls_box.pack_start(self.button_stop, False, False, 0)
        sim_controls_box.pack_start(self.button_step, False, False, 0)
        sim_controls_box.pack_start(self.button_reset, False, False, 0)

        # pack the map control buttons
        map_controls_box = Gtk.HBox(spacing=5)
        map_controls_box.pack_start(self.button_save_map, False, False, 0)
        map_controls_box.pack_start(self.button_load_map, False, False, 0)
        map_controls_box.pack_start(self.button_random_map, False, False, 0)

        # pack the invisibles button
        invisibles_button_box = Gtk.HBox()
        invisibles_button_box.pack_start(self.button_show_invisibles, False,
                                         False, 0)

        # align the controls
        sim_controls_alignment = Gtk.Alignment(xalign=0.5,
                                               yalign=0.5,
                                               xscale=0,
                                               yscale=0)
        map_controls_alignment = Gtk.Alignment(xalign=0.5,
                                               yalign=0.5,
                                               xscale=0,
                                               yscale=0)
        invisibles_button_alignment = Gtk.Alignment(xalign=0.5,
                                                    yalign=0.5,
                                                    xscale=0,
                                                    yscale=0)
        sim_controls_alignment.add(sim_controls_box)
        map_controls_alignment.add(map_controls_box)
        invisibles_button_alignment.add(invisibles_button_box)

        # create the alert box
        self.alert_box = Gtk.Label()

        # lay out the simulation view and all of the controls
        layout_box = Gtk.VBox()
        layout_box.pack_start(self.drawing_area, False, False, 0)
        layout_box.pack_start(self.alert_box, False, False, 5)
        layout_box.pack_start(sim_controls_alignment, False, False, 5)
        layout_box.pack_start(map_controls_alignment, False, False, 5)
        layout_box.pack_start(invisibles_button_alignment, False, False, 5)

        # apply the layout
        self.window.add(layout_box)

        # show the simulator window
        self.window.show_all()
Пример #12
0
 def new_frame(self):
     self.current_frame = Frame()
Пример #13
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        # TODO - clean -  install gettext
        os.chdir(Globals.pwd)  # required for i18n.py to work
        #gettext.install('JokeMachine', './po', unicode=True)
        #presLan_af = gettext.translation("JokeMachine", os.path.join(Globals.pwd, 'po'), languages=['af'])
        #presLan_af.install()
        #locale.setlocale(locale.LC_ALL, 'af')

        # customize theme
        gtkrc = os.path.join(Globals.pwd, 'resources/gtkrc')
        if os.path.exists(gtkrc):
            logging.debug("Loading resources from %s" % gtkrc)
            gtk.rc_add_default_file(gtkrc)
            settings = gtk.settings_get_default()
            #gtk.rc_reset_styles(settings)
            gtk.rc_reparse_all_for_settings(settings, True)
            logging.debug("Loading resources DONE")

        Globals.set_activity_instance(self)

        logging.debug("Starting the Joke Machine activity")

        # toolbox
        self.__toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(self.__toolbox)

        # main activity frame
        self.__activity_frame = Frame()
        vbox = gtk.VBox()
        vbox.pack_start(self.__activity_frame)
        vbox.show()
        self.set_canvas(vbox)
        self.show_all()

        # Initialize mesh ##########################################################

        # init Presence Service
        self.__presence_service = presenceservice.get_instance()
        try:
            name, path = self.__presence_service.get_preferred_connection()
            self.__telepathy_connection = telepathy.client.Connection(
                name, path)
            self.__telepathy_initiating = None
        except TypeError:
            logging.debug('Presence service offline')

        # Buddy object for you
        owner = self.__presence_service.get_owner()
        Globals.set_owner(owner)

        self.__session = None  # JokeMachineSession
        self.connect('shared', self.__do_activity_shared)

        # Check if we're joining another instance
        self.__is_initiator = True
        if self._shared_activity is not None:
            self.alert(
                _('Joke Machine'),
                _('Please wait a moment for your buddy\'s Jokebooks to show up'
                  ))
            self.__is_initiator = False
            logging.debug('shared:  %s' % self._shared_activity.props.joined)
            # We are joining the activity
            logging.debug('Joined activity')
            self.connect('joined', self.__do_activity_joined)
            self._shared_activity.connect('buddy-joined',
                                          self.__do_buddy_joined)
            self._shared_activity.connect('buddy-left', self.__do_buddy_left)
            if self.get_shared():
                # We've already joined
                self.__do_activity_joined()
        else:
            logging.debug('Created activity')

        # ##########################################################################

        # set default startup page if we're the initiator
        if self.is_initiator:
            self.set_page(pages.choose.Choose)