def __init__(self, main_map): self.map = main_map self._clock = pygame.time.Clock() pygame.init() self.screen = screen = pygame.display.set_mode((1024, 760), pygame.DOUBLEBUF) pygame.display.set_caption('MCC - Mission Control Center') #Create the background #graph_tile = pygame.image.load('background.jpg').convert() #graph_rect = graph_tile.get_rect() #background = pygame.Surface(screen.get_size()) #background.blit(graph_tile, graph_rect) #Display The Background #screen.blit(background, (0, 0)) # Init GUI self.re = Renderer() self.re.screen = screen btn = Button("Click") btn.topleft = (10, 10) btn.connect_signal(Constants.SIG_CLICKED, self.success, btn) console = ScrolledWindow(1004, 100) console.topleft = (10, 650) console.child = self.label self.label.multiline = True self.re.add_widget(btn) self.re.add_widget(console) self.map_surface = pygame.Surface((604, 604)) threading.Thread.__init__(self)
# Initialize pygame window pygame.init () screen = pygame.display.set_mode ((200, 200)); screen.fill ((255, 200, 100)) # Create the Renderer to use for the UI elements. re = Renderer () # Bind it to a part of the screen, which it will use to draw the widgets. # Here we use the complete screen. re.screen = screen # Create a button, place it at x=10, y=30, bind a callback to its # clicking action and add it to the Renderer instance. button = Button ("Simple Button") button.topleft = 10, 30 button.connect_signal (Constants.SIG_CLICKED, _count_clicks, button) re.add_widget (button) # Some variables we will need in the main loop for drawing a rect. rnd = None color = None cnt = 100 while True: events = pygame.event.get () for ev in events: if ev.type == pygame.QUIT: sys.exit () # We could handle other events separately, too, but do not care.
# Theme usage example. from ocempgui.widgets import base, Renderer, Button, Label # Load the theme. base.GlobalStyle.load ("theme_example.rc") # Create screen. re = Renderer () re.create_screen (200, 100) re.title = "Theme example" re.color = (250, 250, 250) # Create widgets. button = Button ("Button") button.topleft = 5, 5 label = Label ("Label") label.topleft = 100, 5 re.add_widget (button, label) re.start ()