Beispiel #1
0
def build_textboxes():
    """Crear textboxes"""
    box_1 = TextBox((100, 430, 100, 20), id="name_con", active=True,
                        clear_on_enter=False, inactive_on_enter=True)
    box_2 = TextBox((100, 460, 100, 20), id="name_con", active=False,
                                clear_on_enter=False, inactive_on_enter=True)
    return box_1, box_2
Beispiel #2
0
 def __init__(self, screen, text="", buttons=[], target=0, title=""):
     self.screen = screen
     # 枠線の色
     self.outline_color = (50, 50, 50)
     center_x, center_y = WIDTH // 2, HEIGHT // 2
     self.rect = Rect(center_x - 250, center_y - 150, 500, 300)
     # タイトルの作成
     self.title = None
     if title != "":
         self.title = TextBox(screen, self.rect.left, self.rect.top, 500, 32, title, \
                              font_size=25, outline_color=self.outline_color, outline_size=5)
     # メッセージの描画領域を作成
     x, y = WIDTH // 2 - 230, HEIGHT // 2 - 100
     self.textbox = TextBox(screen, x, y, 460, 155, text, outline_color=(255,)*3, \
                            font_size=25, align=('center', 'center'))
     # ボタンの作成
     self.buttons = []
     self.button_id = target
     self.button_size = len(buttons) or 1
     frame = 500 / self.button_size
     x = self.rect.left + frame / 2 - 50
     y = self.rect.bottom - 80
     for button in buttons:
         button = TextBox(screen,
                          x,
                          y,
                          100,
                          50,
                          button,
                          outline_color=(255, 255, 255),
                          align=('center', 'center'))
         x += frame
         self.buttons.append(button)
     # 時間管理
     self.clock = pygame.time.Clock()
Beispiel #3
0
    def __init__(self):
        pygame.init()
        self.input = []
        pygame.display.set_caption("Hexon Sign Up")
        self.screen = pygame.display.set_mode((450, 800))
        self.clock = pygame.time.Clock()
        # Font Selection (Any_installed_font_on_PC, font_size)
        self.font = pygame.font.SysFont("01 Digitall", 35)
        self.fps = 60.0
        self.done = False
        # TextBoxes configurations:
        self.useremail_input = TextBox((85, 278, 305, 45),
                                       font=self.font,
                                       command=self.save_username,
                                       clear_on_enter=False,
                                       inactive_on_enter=True)
        username_input = TextBox((85, 364, 305, 45),
                                 font=self.font,
                                 command=self.save_email,
                                 clear_on_enter=False,
                                 inactive_on_enter=True,
                                 active=False)
        password_input = TextBox((85, 453, 305, 45),
                                 font=self.font,
                                 command=self.save_password,
                                 clear_on_enter=False,
                                 inactive_on_enter=True,
                                 active=False)

        self.prompts = self.make_labels()
        self.inputs = [useremail_input, username_input, password_input]
        self.input_data = {'Email': "", 'Username': "", 'Password': ""}
        self.color = (100, 100, 100)
        pygame.key.set_repeat(*KEY_REPEAT_SETTING)
Beispiel #4
0
    def __init__(self):
        # INITIALIZATION
        pygame.init()
        self.screen = pygame.display.set_mode((800, 550))
        self.start_button = Button((10, 10, 100, 50), self.screen, "Start", 33)
        self.restart_button = Button((120, 10, 100, 50), self.screen,
                                     "Restart", 33)

        size = self.screen.get_size()
        self.msg_box = TextBox((0, size[1] - 60, size[0], 50), self.screen, "",
                               33)
        self.msg_box2 = TextBox((size[0] - 250, 0, 250, 50), self.screen, "xD",
                                33)
        self.player_move = True
        self.player_map_pressed_flag = False
        self.cpu_map_pressed_flag = False
        self.state = GameState.SETTING
        self.win = False

        while True:
            self.restart()
            if self.main_loop():
                print("zwyciestwo")
            else:
                print("porażka")
Beispiel #5
0
 def __init__(self):
     pg.init()
     pg.display.set_caption("Multiple Input Boxes")
     self.screen = pg.display.set_mode((1024, 700), pg.RESIZABLE)
     self.clock = pg.time.Clock()
     self.fps = 60.0
     self.done = False
     files = glob.glob('files/*[!.dat]')
     self.inputs = []
     print(files)
     for i, file in enumerate(files):
         box = TextBox(((100 * (i - 1)), 50, 75, 40),
                       command=self.change_color,
                       clear_on_enter=True,
                       inactive_on_enter=False,
                       active=False)
         self.inputs.append(box)
     screen_color = TextBox((100, 100, 150, 30),
                            command=self.change_color,
                            clear_on_enter=True,
                            inactive_on_enter=False)
     text_color = TextBox((100, 370, 150, 30),
                          command=self.change_text_color,
                          clear_on_enter=True,
                          inactive_on_enter=False,
                          active=False)
     self.prompts = self.make_prompts()
     self.color = (100, 100, 100)
     pg.key.set_repeat(*KEY_REPEAT_SETTING)
    def __init__(self, screen, game):
        ''' An example class to show how to creat custom GUI frames'''
        Frame.__init__(self, screen, (330, 110), (10, 10))

        self.game = game

        self.b1 = Button(self, "Toggle Constant", self.command)
        self.b2 = Button(self,
                         "Toggle Random",
                         self.command2,
                         position=(5, 40))
        self.b3 = Button(self, "Toggle Shape", self.command3, position=(5, 75))

        self.c_Label = Label(self, "False", position=(135, 10))
        self.r_Label = Label(self, "True", position=(135, 45))
        self.s_Label = Label(self, "Random", position=(135, 80))

        self.l1 = Label(self, "Size", position=(235, 10))
        self.tb1 = TextBox(self, (295, 10))

        self.l2 = Label(self, "Density", position=(235, 45))
        self.tb2 = TextBox(self, (295, 45))

        self.l3 = Label(self, "Speed", position=(235, 80))
        self.tb3 = TextBox(self, (295, 80))

        self.textboxes = {
            'size': self.tb1,
            'density': self.tb2,
            'speed': self.tb3
        }
        self.current = 'circle'
Beispiel #7
0
    def __init__(self, resources: Resources) -> None:
        self.ticks = -1
        self.last_finish = -1
        self.best_finish = -1

        font = FontManager(resources.get_path("DejaVuSans.ttf"), size=28)
        white = Color(r=255, g=255, b=255)
        self.timer_textbox = TextBox(font, 50, 100, white)
        self.best_time_textbox = TextBox(font, 50, 150, white)
Beispiel #8
0
    def __init__(self, ui, parent, levelName):
        super(LevelScreen, self).__init__(ui)

        self._parent = parent
        self._levelName = levelName
        self._lastTime = 0

        # Load the level itself
        self._level = Level(self._ui, levelName)

        # Load the level assets
        with open(LEVEL_DIR + levelName + ".c", "rb") as sampleCode:
            self._sampleCode = sampleCode.read()
        with open(LEVEL_DIR + levelName + ".txt", "rb") as helpText:
            self._helpText = helpText.read()
        try:
            with open(LEVEL_DIR + levelName + "-hints.txt", "rb") as hints:
                self._hints = hints.read().split("\n")
        except IOError:
            self._hints = []
        with open("assets/include.h", "rb") as headerFile:
            self.__header = headerFile.read()
            self.__headerLines = len(filter(lambda x: x == "\n",
                                            self.__header))

        # UI elements
        self._linesLabel = LineNumbers(self._ui, (0, 5.75), 46, BLUE_COLOR)
        self._editor = TextEditor(self._ui, (0.625, 5.75), 46, 47)
        self._debug = TextBox(self._ui, (0.625, 5.75), 47, 47)
        self._keysLabel = TextBox(self._ui, (-8, -1), 3, 51, ORANGE_COLOR)
        self._infoLabel = TextBox(self._ui, (-8, -2), 13, 51)
        self._varLabel = TextBox(self._ui, (-8, -5.5), 1, 51, CYAN_COLOR)
        self._statusLabel = TextBox(self._ui, (-8, -6), 1, 102, YELLOW_COLOR)

        self._debugView = False
        self._debugAddr = 0

        self._editor.text = self._sampleCode
        self._keysLabel.text = (
            "\nESC menu | F1 help | F2 reset code | F3 reset level\n"
            "         | F5 run  | F8 processor status")
        self._infoLabel.text = self._helpText
        self._statusLabel.text = "Ready"

        # Spawn players
        self.resetLevel()

        self._updateVarLabel()
Beispiel #9
0
 def __init__(self, user, mode, password, museID=None):
     self.user = user
     self.password = password
     self.museID = museID
     pygame.init()
     self.width = 600
     self.height = 600
     pygame.display.set_caption(user + ' Prediction Session')
     self.screen = pygame.display.set_mode((self.width, self.height))
     self.mode = mode
     self.inputSize = (300, 60)
     self.inputPosition = (self.width / 2 - self.inputSize[0] / 2,
                           self.height / 2 - self.inputSize[1] / 2)
     font = pygame.font.Font(None, 50)
     inputRect = pygame.Rect(self.inputPosition[0], self.inputPosition[1],
                             self.inputSize[0], self.inputSize[1])
     self.input = TextBox(inputRect,
                          clear_on_enter=True,
                          inactive_on_enter=False,
                          font=font)
     self.gameRunning = False
     self.state = PredictionState.MUSE_DISCONNECTED  # 0 = Muse Disconnected, 1 = Session Running, 2 = Finished
     self.setup_marker_streaming()
     self.markers = [
         []
     ]  # Each item is array of 2 items - timestamp + the key which was pressed.
     self.eegData = [
         []
     ]  # Each item is array of timestamp + data for each channel.
     self.get_eeg_stream(0.5)
     self.startTime = time()  # Timestamp of experiment start.
     self.finishTime = 0  # Timestamp of experiment finish.
     self.lastEEGSampleTime = self.startTime
Beispiel #10
0
    def __init__(self, name, width, height):
        self.width = width
        self.height = height
        screen_size = (width, height)

        pygame.init()
        pygame.display.set_caption(name)

        self.screen = pygame.display.set_mode(screen_size)
        self.clock = pygame.time.Clock()
        self.running = False

        self.row = 10
        self.column = 10
        self.pad = 100
        self.maze_screen = 500

        self.cell_size = min(self.maze_screen / self.row,
                             self.maze_screen / self.column)
        self.maze = Maze(self.row, self.column)

        self.text_box = TextBox(675, 150, 250, 100, '10x10')
        self.generate_button = Button(gray, 675, 300, 250, 100, "Generate")
        self.solve_button = Button(gray, 675, 450, 250, 100, "Solve")

        self.player = Player(0, 0)
Beispiel #11
0
    def invoke(self, context, event):

        sce = bpy.context.scene

        if context.object and context.object.type == 'MESH':
            self.bracket_manager = BracketDataManager(
                context,
                snap_type='OBJECT',
                snap_object=context.object,
                name='Bracket')
            self.bracket_slicer = BracektSlicer(context, self.bracket_manager)
        else:
            self.bracket_manager = BracketDataManager(context,
                                                      snap_type='SCENE',
                                                      snap_object=None,
                                                      name='Bracket')
            self.bracket_slicer = None

        help_txt = "DRAW MARGIN OUTLINE\n\nLeft Click on model to place bracket.\n G to grab  \n S to show slice \n ENTER to confirm \n ESC to cancel"
        self.help_box = TextBox(context, 500, 500, 300, 200, 10, 20, help_txt)
        self.help_box.snap_to_corner(context, corner=[1, 1])
        self.mode = 'main'
        self._handle = bpy.types.SpaceView3D.draw_handler_add(
            bracket_placement_draw_callback, (self, context), 'WINDOW',
            'POST_PIXEL')
        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}
Beispiel #12
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.tablegui = TableGUI(self)
        self.setCentralWidget(self.tablegui)    # Central Widget
        self.gui = GUILogic(self)
        self.sidepanel = SidePanel(self)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.sidepanel)
        self.handgui = handGUI(self)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.handgui)
        self.textbox  = TextBox(self)
        self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.textbox)
        
        self.handgui.setStatusTip("Your hand.")
        self.tablegui.setStatusTip("Table")
        
        self.sidepanel.setFixedWidth(100)
        self.handgui.setFixedWidth(100)
        
        menubar = QtGui.QMenuBar(self)
        self.setMenuBar(menubar)
        self.menubar = self.create_menus(menubar)
        self.statusbar = self.statusBar()
        self.resize(850,680)
        self.setWindowTitle("Kasino")
        self.setMinimumSize(700, 500)
        
        text = "Welcome to play Kasino!"
        self.textbox.update_text(text)
    def init_content(self):
        info_box = TextBox(200, 400, bgcolor=colors['white'], alpha=150)
        info_box.set_position([self.terrain.pixel_size[0] + 25, 250])
        info_box.add_default_text("Tower Defence\n\nPlace turrets on the map to protect your base from enemies. You gain money by winning rounds and killing enemies.", align="center")
        self.box_group = pygame.sprite.Group(info_box)

        cannon_button = button.TowerButton(CannonTower, self.terrain, info_box)
        artillery_button = button.TowerButton(ArtilleryTower, self.terrain, info_box)


        self.tower_buttons = GridGroup(pos=[self.terrain.pixel_size[0] + 25, 15], cols=3, rows=3, margin=10)
        self.tower_buttons.add(cannon_button, artillery_button)


        for _ in range(7):
            empty = button.Button(colors['white'], 60, 60)
            self.tower_buttons.add(empty)
            empty.lock()

        start_button = button.Button(colors['green'], 200, 90)
        start_button.set_position((self.terrain.pixel_size[0] + 25, 670))
        start_button.set_icon_text("Start", font_size=50)
        start_button.set_description("Start round 1", info_box)
        start_button.function = self.start_round

        self.description = info_box
        self.start_button = start_button
        self.buttons = pygame.sprite.Group(start_button)
Beispiel #14
0
    def execute(self, context):
        #add a textbox to display information.  attach it to this
        #add a persisetent callback on scene update
        #which monitors the status of the ODC

        #clear previous handlers
        clear_help_handlers()
        global guide_help_app_handle
        guide_help_app_handle = bpy.app.handlers.scene_update_pre.append(
            guide_help_parser)

        global help_display_box
        if help_display_box != None:
            del help_display_box
        help_text = 'Open Dental Guide Help Wizard \n'
        help_text += 'Next Step: ' + 'TBA'

        help_display_box = TextBox(context, 500, 500, 300, 100, 10, 20,
                                   help_text)
        help_display_box.snap_to_corner(context, corner=[0, 1])

        global guide_help_draw_handle
        guide_help_draw_handle = bpy.types.SpaceView3D.draw_handler_add(
            odc_help_draw, (self, context), 'WINDOW', 'POST_PIXEL')
        return {'FINISHED'}
Beispiel #15
0
    def execute(self, context):
        #add a textbox to display information.  attach it to this
        #add a persisetent callback on scene update
        #which monitors the status of the ODC

        #clear previous handlers
        clear_help_handlers()
        global implant_help_app_handle
        implant_help_app_handle = bpy.app.handlers.scene_update_pre.append(
            implant_help_parser)

        global help_display_box
        if help_display_box != None:
            del help_display_box
        help_text = 'Open Dental Implant Help Wizard \n'
        selections = odcutils.implant_selection(
            bpy.context)  #weird, how do I specify better arguments?
        sel_names = [item.name for item in selections]
        help_text += 'Selected Implants: ' + ', '.join(sel_names) + '\n'
        help_text += 'Next Step: ' + 'TBA'

        help_display_box = TextBox(context, 500, 500, 300, 100, 10, 20,
                                   help_text)
        help_display_box.snap_to_corner(context, corner=[0, 1])

        global implant_help_draw_handle
        implant_help_draw_handle = bpy.types.SpaceView3D.draw_handler_add(
            odc_help_draw, (self, context), 'WINDOW', 'POST_PIXEL')
        return {'FINISHED'}
Beispiel #16
0
    def Body(self):
        label = Label(self, self.prompt)
        self.AddComponent(label, expand='h', border=7)

        self.text = TextBox(self, size=(100,25), process_enter=1)
        self.text.SetValue(self.default)
        self.text.OnChar = self.OnTextBoxChar
        self.AddComponent(self.text, expand='h', border=5)
Beispiel #17
0
def interface(heights, widths, game_boards, chibi = False, game_solve = None):
  """
  Function that render and allow to interact with the interface
  heights, widths: sizes of the board
  game_board: object of the actual game
  chibi: if True icons start with easter egg
  """
  global height, width, grid_x, grid_y, board,path_numbers, game_board
  grid_x = 0
  grid_y = 0
  game_board = game_boards
  path_numbers = "initial"
  if chibi:
      path_numbers = "chibi"
  height = heights
  width = widths
  pygame.init()
  ttt = pygame.display.set_mode ((height, width + 50))
  pygame.display.set_caption ('Sudoku')
  board = initBoard (ttt)
  board = initStateBoard(board,game_board)
  board = renderText(board,grid_x,grid_y,game_board)
  boxtext = TextBox((300,widths + 10,150,30),command=dumb,clear_on_enter=True,inactive_on_enter=False)
  running = 1
  if game_solve == None: #Solve by human
      if not chibi:
         path_numbers = "insert"
      while (running == 1):
        #Events created by the player
        for event in pygame.event.get():
            if event.type is QUIT:
                running = 0
            elif event.type is MOUSEBUTTONDOWN:
                (mouseX, mouseY) = pygame.mouse.get_pos()
                grid_y_aux,grid_x_aux = boardPos(mouseX, mouseY)
                if grid_x_aux != None:
                    grid_x = grid_x_aux
                    grid_y = grid_y_aux
                    board = renderText(board,grid_x,grid_y,game_board)
        if game_board.is_win():
            path_numbers = "correct"
            renderBoardAgain(board,game_board)

        boxtext.get_event(event)
        showBoard (ttt, board,boxtext)
  else: #Solve by Machine
      if game_solve:
          path_numbers = "correct"
      else:
          path_numbers = "wrong"
      renderBoardAgain(board,game_board)
      while (running == 1):
          for event in pygame.event.get():
              if event.type is QUIT:
                  running = 0
          boxtext.get_event(event)
          showBoard (ttt, board,boxtext)
Beispiel #18
0
    def build_textfields(self):
        """Construir campos de texto"""
        celda1 = TextBox(
            (self.panel_forma[0] + 250, self.panel_forma[1] + 10, 40, 20),
            buffer=["8"],
            id="cell1",
            clear_on_enter=False,
            inactive_on_enter=True)
        celda2 = TextBox(
            (self.panel_forma[0] + 300, self.panel_forma[1] + 10, 40, 20),
            buffer=["8"],
            id="cell2",
            clear_on_enter=False,
            inactive_on_enter=True)
        bloque1 = TextBox(
            (self.panel_forma[0] + 250, self.panel_forma[1] + 40, 40, 20),
            buffer=["2"],
            id="block1",
            clear_on_enter=False,
            inactive_on_enter=True)
        bloque2 = TextBox(
            (self.panel_forma[0] + 300, self.panel_forma[1] + 40, 40, 20),
            buffer=["2"],
            id="block2",
            clear_on_enter=False,
            inactive_on_enter=True)
        bins = TextBox(
            (self.panel_forma[0] + 250, self.panel_forma[1] + 70, 40, 20),
            buffer=["9"],
            id="bins",
            clear_on_enter=False,
            inactive_on_enter=True)
        self.text_fields_shape = [celda1, celda2, bloque1, bloque2, bins]

        bin1 = TextBox(
            (self.panel_color[0] + 140, self.panel_color[1] + 35, 40, 20),
            buffer=[""],
            id="bin1",
            clear_on_enter=False,
            inactive_on_enter=True)
        bin2 = TextBox(
            (self.panel_color[0] + 190, self.panel_color[1] + 35, 40, 20),
            buffer=[""],
            id="bin2",
            clear_on_enter=False,
            inactive_on_enter=True)
        bin3 = TextBox(
            (self.panel_color[0] + 240, self.panel_color[1] + 35, 40, 20),
            buffer=[""],
            id="bin3",
            clear_on_enter=False,
            inactive_on_enter=True)

        self.text_fields_color = [bin1, bin2, bin3]
Beispiel #19
0
 def invoke(self,context, event):
      
     
     Model = context.object
     
            
     for ob in bpy.data.objects:
         if ob.name == 'Plane': continue
         ob.select = False
         ob.hide = True
     Model.select = True
     Model.hide = False
     
     #bpy.ops.view3d.view_selected()
     self.crv = LineDrawer(context,snap_type ='OBJECT', snap_object = Model)
     context.space_data.show_manipulator = False
     context.space_data.transform_manipulators = {'TRANSLATE'}
     v3d = bpy.context.space_data
     v3d.pivot_point = 'MEDIAN_POINT'
     
     
     #TODO, tweak the modifier as needed
     #help_txt = "Interactive Plane Cutting\n\nLeft click, move the mouse, and left click again.\nThen place your mouse on the side of the line to remove. \n Click on the model to isolate the cut to the line limits.\nClick off the model to cut beyond the end-points of the line."
     help_txt_open = "INTERACTIVE PLANE CUTTING OPEN\n\n-  LeftClick and move mouse to define a line across your model \n-  The line will stick to your mouse until you Left Click again\n-  LeftClick a 3rd time on the side of the line to be cut\n-  If you click on the model, the cut will be limited to the edges of the line \n-  If you click off of the model, the cut will extend into space\n\n\nEXTRUDING\n\n-  A dot will appear next to the most recent cut, you can click and move your mouse to extrude the new cut edge.\n-  LeftClick to confirm the position of the extrusion"
     help_txt_solid = "INTERACTIVE PLANE CUTTING SOLID\n\n-  LeftClick and move mouse to define a line across your model \n-  The line will stick to your mouse until you Left Click again\n-  A blue preview of the region to be deleted will present itself, everything behind the blue preview will be removed from the model\n-  LeftClick a 3rd time to confirm and the operator will end"
     
     if self.cut_method == 'SOLID':
         help_txt = help_txt_solid
     else:
         help_txt = help_txt_open
     self.help_box = TextBox(context,500,500,300,200,10,20,help_txt)
     self.help_box.snap_to_corner(context, corner = [1,1])
     self.mode = 'main'
     self._handle = bpy.types.SpaceView3D.draw_handler_add(plane_cut_draw_callback, (self, context), 'WINDOW', 'POST_PIXEL')
     context.window_manager.modal_handler_add(self) 
     
     self.bme= bmesh.new()
     self.bme.from_mesh(Model.data)
     self.ob = Model
     self.cursor_updated = True
     
     
     self.new_geom = []
     self.new_geom_point = Vector((0,0,0))
     self.new_geom_draw_points = []
     
     self.extrude_verts = []
     self.extrude_origins = dict()
     self.extrude_geom_draw_points = []
     
     
     
     self.new_geom_color = (.8, .8, .1, 1)
     self.new_geom_point_color = (.1, .1, .8, 1)
     
     return {'RUNNING_MODAL'}
Beispiel #20
0
    def prep_world(self):
        self.world_text = TextBox(self.settings, self.screen)
        self.world_text.update_text("WORLD")
        self.world_text.text_rect.centerx = self.settings.screen_width / 2
        self.world_text.text_rect.top = self.screen_rect.top + 5

        self.world_image = self.font.render(self.settings.world_level, True, self.text_color, self.settings.bg_color)
        self.world_rect = self.world_image.get_rect()
        self.world_rect.centerx = self.world_text.text_rect.centerx
        self.world_rect.top = self.world_text.text_rect.bottom
Beispiel #21
0
    def invoke(self, context, event):
        settings = get_settings()
        dbg = settings.debug

        if context.space_data.region_3d.is_perspective:
            #context.space_data.region_3d.is_perspective = False
            bpy.ops.view3d.view_persportho()

        if context.space_data.type != 'VIEW_3D':
            self.report({'WARNING'}, "Active space must be a View3d")
            return {'CANCELLED'}

        #gather all the teeth in the scene TODO, keep better track

        self.target = 11
        self.message = "Set axis for " + str(self.target)

        if context.mode != 'OBJECT':
            bpy.ops.object.mode_set(mode='OBJECT')

        #check for an armature
        bpy.ops.object.select_all(action='DESELECT')

        help_txt = "Left click on the tooth indicated to label it. Right click skip a tooth \n Up or Dn Arrow to change label\n Enter to finish \n ESC to cancel"
        self.help_box = TextBox(context, 500, 500, 300, 200, 10, 20, help_txt)
        self.help_box.fit_box_width_to_text_lines()
        self.help_box.fit_box_height_to_text_lines()
        self.help_box.snap_to_corner(context, corner=[1, 1])

        aspect, mid = menu_utils.view3d_get_size_and_mid(context)
        self.target_box = TextBox(context, mid[0], aspect[1] - 20, 300, 200,
                                  10, 20, self.message)
        self.target_box.format_and_wrap_text()
        self.target_box.fit_box_width_to_text_lines()
        self.target_box.fit_box_height_to_text_lines()

        self.mode = 'main'
        context.window_manager.modal_handler_add(self)
        self._handle = bpy.types.SpaceView3D.draw_handler_add(
            rapid_label_teeth_callback, (self, context), 'WINDOW',
            'POST_PIXEL')
        return {'RUNNING_MODAL'}
 def __init__(self):
     pg.init()
     pg.display.set_caption("Multiple Input Boxes")
     self.screen = pg.display.set_mode((500, 500))
     self.clock = pg.time.Clock()
     self.fps = 60.0
     self.done = False
     screen_color = TextBox((100, 100, 150, 30),
                            command=self.change_color,
                            clear_on_enter=True,
                            inactive_on_enter=False)
     text_color = TextBox((100, 370, 150, 30),
                          command=self.change_text_color,
                          clear_on_enter=True,
                          inactive_on_enter=False,
                          active=False)
     self.prompts = self.make_prompts()
     self.inputs = [screen_color, text_color]
     self.color = (100, 100, 100)
     pg.key.set_repeat(*KEY_REPEAT_SETTING)
Beispiel #23
0
    def prep_coins(self):
        self.coin_text = TextBox(self.settings, self.screen)
        self.coin_text.update_text("COINS")
        self.coin_text.text_rect.centerx = self.lives_rect.centerx - 175
        self.coin_text.text_rect.top = self.screen_rect.top + 5

        coin_str = " {:,}".format(self.settings.coin_count)
        self.coin_image = self.font.render(coin_str, True, self.text_color, self.settings.bg_color)
        self.coin_rect = self.coin_image.get_rect()
        self.coin_rect.centerx = self.coin_text.text_rect.centerx
        self.coin_rect.top = self.coin_text.text_rect.bottom
Beispiel #24
0
 def __init__(self):
     self.screen = pygame.display.set_mode((1300,600))
     #self.screen_rect = self.screen.get_rect()
     self.bnum = 0
     
     self.clock = pygame.time.Clock()
     self.done = False
     self.fps = 60.0
     self.color = GREEN
     message, message2, message3, message4, message5, message6, message7, message8 = ("Host", "SensorNode 1",
                                     "SensorNode 2","SensorNode 3",
                                     "Communication", "Alarm", "Battery", "Change password")
     #button style
     self.button = Button((0,0,150,100),RED, self.button_click,
                          text=message, **BUTTON1_STYLE)
     #button move
     #self.button.rect.center = (self.screen_rect.centerx,100)
     
     self.button2 = Button((0,100,150,100),RED, self.button_click2,
                          text=message2, **BUTTON1_STYLE)
     self.button3 = Button((0,200,150,100),RED, self.button_click3,
                          text=message3, **BUTTON1_STYLE)
     self.button4 = Button((0,300,150,100),RED, self.button_click4,
                          text=message4, **BUTTON1_STYLE)
     self.button5 = Button((0,400,150,100),RED, self.button_click5,
                          text=message5, **BUTTON1_STYLE)
     self.button6 = Button((0,500,150,100),RED, self.button_click6,
                          text=message6, **BUTTON1_STYLE)
     self.button7 = Button((0,600,100,100),RED, self.button_click,
                          text=message7, **BUTTON1_STYLE)
     self.button8= Button((0,700,100,100),RED, self.button_click,
                          text=message8, **BUTTON1_STYLE)
     #input
     
     self.b2_input = TextBox((450,270,150,25),command=self.change_color2,
                           clear_on_enter=True,inactive_on_enter=False)
     
     pygame.key.set_repeat(*KEY_REPEAT_SETTING)
     
     #mesk
     
     self.pnum, self.pnum2, self.pnum3 = 0,0,0
     
     self.photo = pygame.image.load('p1.1.png').convert_alpha()
     self.photo_pos = (550, 55)
     self.mask = pygame.mask.from_surface(self.photo)
     
     self.photo2 = pygame.image.load('p1.3.png').convert_alpha()
     self.photo2_pos = (400, 200)
     self.mask2 = pygame.mask.from_surface(self.photo2)
     
     self.photo3 = pygame.image.load('p2.1.png').convert_alpha()
     self.photo3_pos = (410, 345)
     self.mask3 = pygame.mask.from_surface(self.photo3)
Beispiel #25
0
 def set_icon_text(self, text, font_size=20):
     textbox = TextBox(self.width, self.height)
     textbox.add_text(text, align="center", font_size=font_size, color=colors['black'])
     
     self.icon = textbox.image
     self.blurred_icon = self.icon.copy()
     image = pygame.Surface([self.width, self.height])
     image.fill(colors['gray'])
     image.set_alpha(240)
     self.blurred_icon.blit(image, (0,0))
     self.icon_pos = [self.rect.width/2 - self.width/2, self.rect.height/2 - self.height/2]
     self.image.blit(self.icon, self.icon_pos)
Beispiel #26
0
    def prep_lives(self):
        """Turn level into a rendered image"""
        self.lives_text = TextBox(self.settings, self.screen)
        self.lives_text.update_text("LIVES")
        self.lives_text.text_rect.right = self.settings.screen_width - 50
        self.lives_text.text_rect.top = self.screen_rect.top + 5

        lives_str = " {:,}".format(self.settings.lives)
        self.lives_image = self.font.render(lives_str, True, self.text_color, self.settings.bg_color)
        self.lives_rect = self.lives_image.get_rect()
        self.lives_rect.centerx = self.lives_text.text_rect.centerx
        self.lives_rect.top = self.lives_text.text_rect.bottom
Beispiel #27
0
    def prep_timer(self):
        timer_str = "{:,}".format(self.settings.timer)
        self.timer_image = self.font.render(timer_str, True, self.text_color, self.settings.bg_color)

        self.timer_text = TextBox(self.settings, self.screen)
        self.timer_text.update_text("TIMER")
        self.timer_text.text_rect.centerx = self.score_text.text_rect.centerx + 175
        self.timer_text.text_rect.top = self.screen_rect.top + 5

        #  Display the score at the top right of the screen
        self.timer_rect = self.timer_image.get_rect()
        self.timer_rect.centerx = self.score_text.text_rect.centerx + 175
        self.timer_rect.top = self.timer_text.text_rect.bottom
Beispiel #28
0
 def __init__(self, window):
     self.player = Player()
     self.loop = True
     self.window = window
     width, height = self.window.get_size()
     self.background = pg.image.load(join(DATA_DIR,
                                          'floor-1256804.jpg')).convert()
     self.background = pg.transform.scale(self.background, (width, height))
     self.sheet = pg.Rect(100, 100, 800, 500)
     self.input = TextBox((110, 110, 150, 30),
                          command=self.player.set_name,
                          inactive_on_enter=False,
                          active_color=pg.Color('gray'))
    def __init__(self, textbox=None):
        super(TextWindow, self).__init__()
        if textbox is None:
            textbox = TextBox()

        self.vbox = gtk.VBox()
        self.add(self.vbox)

        self.textbox = textbox
        self.vbox.add(textbox)

        self.connect('destroy', lambda *args: gtk.main_quit())
        self.set_size_request(600, 100)
Beispiel #30
0
    def prep_score(self):
        """Turn the score into a rendered image"""
        self.score_text = TextBox(self.settings, self.screen)
        self.score_text.update_text("SCORE")
        self.score_text.text_rect.top = self.screen_rect.top + 5
        self.score_text.text_rect.left = self.screen_rect.left + 50
        self.score_str = "{:,}".format(self.settings.score)
        self.score_image = self.font.render(self.score_str, True, self.text_color, self.settings.bg_color)

        #  Display the score at the top right of the screen
        self.score_rect = self.score_image.get_rect()
        self.score_rect.centerx = self.score_text.text_rect.centerx
        self.score_rect.top = self.score_text.text_rect.bottom