def open_it(self): Window.activateFakewin(self.fakewin.winId()) self.plugin=False self.sys_win.close() self.open_win.close() self.dock_options_win.close() while self.pos_x<self.s_width/3-5: self.current_state='nothing' if self.pos_x<self.s_width/7: self.pos_x=self.s_width/7 else: self.pos_x+=float(self.conf["animation-speed"]) self.setGeometry(0,self.top_pos,self.s_width/3+5,self.s_height) self.update() QtGui.QApplication.processEvents() if self.pos_x!=self.s_width/3-2 : self.pos_x=self.s_width/3-2 self.current_state="open" if self.activity=="apps": self.allApps=Apps.info(self.current_text) self.setAttribute(QtCore.Qt.WA_X11NetWmWindowTypeDock,False) self.windowActivationChange(True) self.resetInputContext() self.webview.setEnabled(True) self.webview.setFocus(True) self.webview.resetInputContext() self.update() self.windowActivationChange(True) QtGui.QApplication.processEvents()
def __init__(self): QtGui.QMainWindow.__init__(self,None,QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.FramelessWindowHint) self.setAttribute(QtCore.Qt.WA_TranslucentBackground,True) self.setAttribute(QtCore.Qt.WA_X11NetWmWindowTypeDock,True) self.setWindowTitle("ducklauncher!!")#recognisable by wnck self.activateWindow() #screen size d = QtGui.QDesktopWidget() self.top_pos=0 self.s_width = d.availableGeometry().width() self.s_height =d.availableGeometry().height() self.top_pos= d.availableGeometry().y() #Config values conf=Config.get() self.conf=conf self.HALF_OPEN_POS=int(conf['size']) self.ICO_TOP=self.HALF_OPEN_POS-5 self.OPEN_STATE_TOP=self.ICO_TOP*4+5 self.SIZE = 14 #Geometry self.setGeometry(0,self.top_pos,self.HALF_OPEN_POS+9,self.s_height) #Values self.ICON_SIZE=int(conf['icon-size']) self.apps_per_row = math.trunc(((self.s_width/3)-50)/ int(self.conf["icon-size"])) self.apps_per_col = math.trunc(((self.s_height)-90)/ int(self.conf["icon-size"])) self.apps_per_page=self.apps_per_col*self.apps_per_row self.app_page_state=0 self.appRect=None self.drawAppRect=False self.pos_x=self.HALF_OPEN_POS-2 self.move=False self.current_state="half_open" self.activity="apps" self.dock_apps = Apps.find_info(self.conf['dock-apps']) self.current_text='' self.allApps=Apps.info(self.current_text) self.plugin=False self.pl_rect_pos=0 self.pl_logo=None self.fg_color=(int(self.conf['r']),int(self.conf['g']),int(self.conf['b'])) self.font_color=(int(self.conf['font-r']),int(self.conf['font-g']),int(self.conf['font-b'])) ##Windows #Enables the server which gets open windows self.op_thread=Window.openWindowsThread() self.op_thread.start() self.connect(self.op_thread,QtCore.SIGNAL("new-window"),self.addOpenWindow) self.connect(self.op_thread,QtCore.SIGNAL("remove-window"),self.updateOpenWindows) self.open_windows=Window.get_open_windows() self.ow_in_dock=[] #Dock Apps Options Window self.dock_options_win=DockAppsOptions.Window(parent=self) #Webview (for plugins, files, and settings view) self.webview=Widgets.pluginView(self) self.webview.setGeometry(2,60,self.s_width/3-20,self.s_height-60) #System window self.sys_win=System.Window() #Fake window, required to capture keyboard events self.fakewin = Fakewin(10,10, self) self.fakewin.show() XlibStuff.fix_window(self.winId(),self.HALF_OPEN_POS+3,0,0,0)
def main(): global Players print("System started!") clock = pygame.time.Clock() length = data.DEF_LEN size = data.DEF_SIZE state = 0 Sys_IP = socket.gethostbyname(socket.gethostname()) link = "http://" + Sys_IP + "/" print(link) qr = qrcode.make(link).resize((350, 350)).convert("RGB") qrc = pygame.image.frombuffer(qr.tobytes(), qr.size, "RGB") while CM.isRunning: pygame.time.delay(20) clock.tick(15) ac = Game.activePlayers() input = Window.checkInput() if input is not None: if input[pygame.K_UP]: if state == 0: if length < 15: length = length + 1 elif state == 1: if size < len(data.SIZE_SET) - 1: size = size + 1 elif input[pygame.K_DOWN]: if state == 0: if length > 1: length = length - 1 elif state == 1: if size > 0: size = size - 1 elif input[pygame.K_LEFT]: if state > 0: state = state - 1 elif input[pygame.K_RIGHT]: if state < 2: state = state + 1 elif input[13]: # index 13=Enter if state < 2: state = 2 elif state == 2: if len(ac) > 0: Game.start(data.SIZE_SET[size], length, ac) for P in Players: P.getInput() ac = Game.activePlayers() length = data.DEF_LEN size = data.DEF_SIZE state = 0 Window.drawMenu(state, length, data.SIZE_SET[size], qrc, link, getAcColores(ac), getInacColores()) for P in Players: P.getController() P.getColor()
def __init__(self): self.window = Window(NUM_CASE_X, NUM_CASE_Y, CASE_SIZE) self.map = [] for i in range(0, NUM_CASE_X): self.map.append([]) for j in range(0, NUM_CASE_Y): self.map[i].append(0) self.window.createRect(i, j, 0)
def Main(): client = mqtt.Client() client.username_pw_set(username = "******", password = "******") client.on_connect = on_connect client.on_message = on_message client.connect("192.168.43.62", 1884, 60) HTSensor.getTemperatureAndHumidity(client) Window.window(client) client.loop_forever()
def __init__(self): self.win = Window() self.win.create_map() self.user_input = '' self.show_screen = True self.has_changed = True self.general_offset = Params.map_current_offset self.arrow_move_speed = 20 self.drag_flag = False
def __reset(self): """ Resets the game and all its objects :return: """ self.map = None self.mapFile = self.__loadMap() self.window = Window( len(self.mapFile[0]) * BaseTile.WIDTH, len(self.mapFile) * BaseTile.HEIGHT) self.renderMenu = True self.enemies.empty()
def __init__(self): QtGui.QMainWindow.__init__(self, None,QtCore.Qt.WindowStaysOnTopHint|QtCore.Qt.FramelessWindowHint)#| QtCore.Qt.X11BypassWindowManagerHint) self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setWindowTitle("ducklauncher")#recognisable by wnck #screen size d = QtGui.QDesktopWidget() self.top_pos=0 self.s_width = d.availableGeometry().width() self.s_height =d.availableGeometry().height() d.resized.connect(self.updateSize) #Config conf=Config.get() self.conf=conf self.HALF_OPEN_POS=int(conf['size']) self.ICO_TOP=self.HALF_OPEN_POS-5 self.OPEN_STATE_TOP=self.ICO_TOP*4+5 self.SIZE = 15 self.R=int(conf['r']) self.G=int(conf['g']) self.B=int(conf['b']) self.ICON_SIZE=int(conf['icon-size']) #Geometry self.setGeometry(0,0,self.HALF_OPEN_POS+4,self.s_height) #reserve wndow space #self.activateWindow() xwin = XlibStuff.fix_window(self.winId(),self.HALF_OPEN_POS+5,0,0,0) # #Values self.apps_per_row = math.trunc(((self.s_width/3)-30)/self.ICON_SIZE) self.apps_per_col = math.trunc(((self.s_height)-30)/self.ICON_SIZE) self.apps_per_page=self.apps_per_col*self.apps_per_row self.app_page_state=0 self.files_page_state=0 self.Files = Files.getFiles() self.pos_x=self.HALF_OPEN_POS self.move=False self.current_state="half_open" self.activity="apps" self.dock_apps = Apps.find_info(self.conf['dock-apps']) self.current_text='' #Update open windows self.timer=QtCore.QTimer() self.timer.setInterval(2000) self.timer.start() self.timer.timeout.connect(self.updateOpenWindows) # self.open_windows=window.get_open_windows() self.open_win = window.open_windows() self.open_state=False # self.settings_win = Settings.Window(self)
def __init__(self): self.player = Player(math.ceil((self.worldSize - 1) / 2), math.ceil((self.worldSize - 1) / 2), Window.tileSize) self.window = Window(self.worldSize) self.window.master.bind("<KeyPress>", self.keyDown) self.player.setShape( self.window.canvas.create_rectangle( self.player.position[0] * self.player.size, self.player.position[1] * self.player.size, self.player.position[0] * self.player.size + self.player.size, self.player.position[1] * self.player.size + self.player.size, fill="black", outline="")) self.objectHandler = ObjectHandler(self.window.canvas)
def set_href(self, url): referer = self._window.url if referer == url: log.warning("Detected redirection from %s to %s... skipping" % ( referer, url, )) return for p in log.ThugOpts.Personality: if log.ThugOpts.Personality[p][ 'userAgent'] == self._window._navigator.userAgent: break url = self._window.navigator._normalize_url(url) log.ThugLogging.log_href_redirect(referer, url) doc = w3c.parseString('') window = Window.Window(referer, doc, personality=p) window = window.open(url) if not window: return #self._window.url = url dft = DFT.DFT(window) dft.run()
def set_href(self, url): if re.search('ms-help',str(url).lower()): log.ThugLogging.add_behavior_warn(description = "[ASLR Bypass Detected: ms-help] %s" % str(url), method = 'Dynamic Analysis') referer = self._window.url if referer == url: log.warning("Detected redirection from %s to %s... skipping" % (referer, url, )) return for p in log.ThugOpts.Personality: if log.ThugOpts.Personality[p]['userAgent'] == self._window._navigator.userAgent: break url = self._window.navigator._normalize_url(url) log.ThugLogging.log_href_redirect(referer, url) doc = w3c.parseString('') window = Window.Window(referer, doc, personality = p) window = window.open(url) if not window: return #self._window.url = url dft = DFT.DFT(window) dft.run()
def begin_visualization(self): """ Begins Visualization Analysis for user selected plots. """ filename = visualization_values['plot_filename'] if not Window.validate_path(filename): plot = visualization_values['requested_plot'] if self.selection_dialog.get_number_sensors() == 2: # Requires 2 Sensors. if self.selection_dialog.validate_visualize_sensor_selection(2): if plot == CPS_PLOT: self.plot_cps(filename) elif plot == PHASE_PLOT: self.plot_phase(filename) elif plot == COHERENCE_PLOT: self.plot_cohere(filename) else: self.display_error('Sensor not selected.') elif self.selection_dialog.get_number_sensors() == 1: # Only have to Validate One Sensor. if self.selection_dialog.validate_visualize_sensor_selection(1): # Choose which Plot. if plot == TIME_PLOT: self.plot_time(filename) elif plot == FREQ_PLOT: self.plot_fft(filename) elif plot == APS_PLOT: self.plot_aps(filename) else: self.display_error('Sensor not selected.') else: self.display_error('File name or Path incorrect.1 <br> <br>' 'Choose a File from: C://[USER PATH]/EWAS_Applocation/Data/')
def action_store_location(self): """ Store Location Information as CSV File. """ # Get filename from User self.filename_input_win.open() filename = self.filename_input_win.fn_in.text() if Window.validate_filename(filename): # Get info from GUI. # get_location_from_gui() loc_type = self.loc_type_dropdown.currentIndex() if not loc_type: if not self.validate_gps_location_settings(): # Save to File. self.setting_manager.store_location_configs(filename) # Close Window self.filename_input_win.close() else: self.display_error(self.validate_gps_location_settings()) else: if not self.validate_module_location_settings(): # Save to File. self.setting_manager.store_location_configs(filename) # Close Window self.filename_input_win.close() else: self.display_error(self.validate_module_location_settings()) self.filename_input_win.close() pass
def Warn(): city=Save.get_city() if city==None: return msg = [] weather_info = weather.get_weather_info(city[1]) if weather_info == None: return [] if weather_info.today_rain and weather_info.tomorrow_rain: msg.append("今明两天的天气是:{weather} 出门记得带好雨伞".format( weather=weather_info.tomorrow_wearther)) elif weather_info.today_rain: msg.append("今天的天气是{weather} 记得带好雨伞".format( weather=weather_info.today_weather)) elif weather_info.tomorrow_rain: msg.append("明天的天气是:{weather} 记得准备好雨伞".format( weather=weather_info.tomorrow_wearther)) if int(weather_info.today_max_tmp)-int(weather_info.tomorrow_max_tmp) >= 10: msg.append("明天的最高气温是:{tmp}℃\n寒潮来袭 记得增添衣物\n".format( tmp=weather_info.tomorrow_max_tmp)) elif int(weather_info.tomorrow_max_tmp) >= 35: msg.append("明天的最高气温是:{tmp}℃\n气温过高 注意防暑\n".format( tmp=weather_info.tomorrow_max_tmp)) if len(msg) > 0: Window.MessageBox(msg)
def main(): # #test.mclass() # siusiak = [1, -4, 3] # print(np.roots(siusiak)) window = Window.Interface() window.mainwindow() pass
def handle_frame(self, frame, redirect_type = 'frame'): log.warning(frame) src = frame.get('src', None) if not src: return try: response, content = self.window._navigator.fetch(src, redirect_type = redirect_type) except: return if response.status == 404: return if 'content-type' in response: handler = log.MIMEHandler.get_handler(response['content-type']) if handler and handler(content): return _src = self.window._navigator._normalize_url(src) if _src: src = _src doc = w3c.parseString(content) window = Window.Window(self.window.url, doc, personality = log.ThugOpts.useragent) window.open(src) frame_id = frame.get('id', None) if frame_id: log.ThugLogging.windows[frame_id] = window dft = DFT(window) dft.run()
def __init__(self): QMainWindow.__init__(self) self.setWindowTitle("Silent Observer") self.setWindowIcon(QIcon('silent_observer2.png')) self.setGeometry(400, 200, 1100, 700) self.setFixedSize(1100, 700) self.form_widget = Window.Window() self.setCentralWidget(self.form_widget) p = QPalette() p.setColor(QPalette.Background, Qt.white) self.setAutoFillBackground(True) self.setPalette(p) menubar = self.menuBar() file = menubar.addMenu('file') edit = menubar.addMenu('edit') help = menubar.addMenu('help') open = QAction('open', self) save = QAction('save', self) exit = QAction('exit', self) manual = QAction('guide', self) sniff = QAction('how to sniff', self) file.addAction(open) file.addAction(save) file.addAction(exit) help.addAction(manual) help.addAction(sniff) self.show()
def __init__(self): self.listener = Listener.Listener() self.window = Window.Window("Not Listening") self.running = True self.wasListening = False self.listening = False self.engine = pyttsx.init()
def follow_href(self, href): doc = w3c.parseString('') window = Window.Window(self.window.url, doc, personality = log.ThugOpts.useragent) window = window.open(href) if window: dft = DFT(window) dft.run()
def onClick(self, sender): if (sender == self.signOutLink): Window.alert("If this were implemented, you would be signed out now.") elif (sender == self.aboutLink): # When the 'About' item is selected, show the AboutDialog. # Note that showing a dialog box does not block -- execution continues # normally, and the dialog fires an event when it is closed. dlg = AboutDialog() # Position it roughly in the middle of the screen. left = (Window.getClientWidth() - 512) / 2 top = (Window.getClientHeight() - 256) / 2 #Logger("TopPanel", "left: " + left) #Logger("TopPanel", "top: " + top) dlg.setPopupPosition(left, top) dlg.show()
def open_it(self): Window.activateFakewin(self.fakewin.winId()) self.sys_win.close() self.open_win.close() while self.pos_x<self.s_width/3: self.current_state='nothing' if self.pos_x<self.s_width/7: self.pos_x=self.s_width/7 else: self.pos_x+=1.5 self.setGeometry(0,self.top_pos,self.s_width/3+5,self.s_height) self.update() QtGui.QApplication.processEvents() self.current_state="open" if self.activity=="apps": self.allApps=Apps.info(self.current_text) self.update()
def generate(self,kind=""): td = self.getSection('Window') #tofill td = self.getSection('Logger') lfile = td['external'] factory = DBFactory.DBFactory(self.configuration_file) dataman = factory.generate('Window') retval = Window.Window(lfile,dataman) return retval
def main(): arena = Arena.Arena() player1 = Player.Player('Wojtek', 11, Stats.hp, Stats.str, Stats.agi, 1, 'X') player2 = Player.Player('Seba',14, Stats.hp, Stats.str, Stats.agi, 0, 'O') arena.generate(player1.position, player2.position) now_playing = player1 prev_playing = player2 arena.show(player1.position, player2.position) Window.Window(arena, now_playing, prev_playing)
def onSave(self): """ Handle the save click and pass it onto the listeners """ console.log("onSave() in %s", Window.getLocation().getHref()) for listener in self.saveListeners: if listener.onSave: listener.onSave(self) else: listener(self) return False
def main(): if len(sys.argv) != 5: return(die("usage: python3 main.py [FRACTAL] [WIN_HEIGHT] [WIN_WIDTH] [MAX_ITERATIONS]")) if sys.argv[1].isnumeric() or not sys.argv[2].isnumeric() or not sys.argv[3].isnumeric() or not sys.argv[4].isnumeric(): return(die("Invalid input")) if int(sys.argv[4]) > 10: return(die("Exceeded Max Iterations")) MAX_ITERATIONS = int(sys.argv[4]) WIN_HEIGHT = int(sys.argv[2]) WIN_WIDTH = int(sys.argv[3]) # How many colors / Symbols are available in palette grid = Window.initWin(WIN_HEIGHT, WIN_WIDTH) if sys.argv[1] == "mandelbrot": Fractals.mandelbrot(grid, WIN_HEIGHT, WIN_WIDTH, MAX_ITERATIONS) Window.printWin(grid) if sys.argv[1] == "julia": julia = Fractals.Fractal() while True: process_input(print_instructions(), julia) Fractals.julia(grid, WIN_HEIGHT, WIN_WIDTH, MAX_ITERATIONS, julia) Window.printWin(grid)
def test_search_free_turn_cell(self): # Проверка поиска (2 белые шашки) field = Field(4, "RU") field.field = \ [[0, 0, 0, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]] answer_list = [((1, 2), (0, 1)), ((1, 2), (2, 1)), ((3, 3), (2, 2))] self.assertEqual(Window.search_free_turn([], True, field), answer_list)
def onClick(self, sender): if (sender == self.signOutLink): Window.alert( "If this were implemented, you would be signed out now.") elif (sender == self.aboutLink): # When the 'About' item is selected, show the AboutDialog. # Note that showing a dialog box does not block -- execution continues # normally, and the dialog fires an event when it is closed. dlg = AboutDialog() # Position it roughly in the middle of the screen. left = (Window.getClientWidth() - 512) / 2 top = (Window.getClientHeight() - 256) / 2 Logger("TopPanel", "left: " + left) Logger("TopPanel", "top: " + top) dlg.setPopupPosition(left, top) dlg.show()
def test_must_turn_king6(self): field = Field(4, "RU") field.field = \ [[0, 0, 0, 0], [4, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0]] answer_list = [] self.assertEqual(Window.must_turn_king([], 0, 1, False, field), answer_list)
def test_free_turn_cell5(self): # Проверка белой шашки 2 хода вперёд field = Field(3, "RU") field.field = \ [[0, 0, 0], [0, 0, 0], [0, 1, 0]] answer_list = [((1, 2), (0, 1)), ((1, 2), (2, 1))] self.assertEqual(Window.free_turn_cell([], 1, 2, True, field), answer_list)
def test_must_turn_king5(self): field = Field(4, "RU") field.field = \ [[0, 0, 0, 4], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0]] answer_list = [((3, 0), (0, 3))] self.assertEqual(Window.must_turn_king([], 3, 0, False, field), answer_list)
def test_must_turn_king2(self): field = Field(4, "RU") field.field = \ [[0, 0, 0, 0], [3, 0, 0, 0], [0, 2, 0, 0], [0, 0, 0, 0]] answer_list = [((0, 1), (2, 3))] self.assertEqual(Window.must_turn_king([], 0, 1, True, field), answer_list)
def test_must_turn_cell15(self): field = Field(4, "RU") field.field = \ [[0, 0, 0, 0], [0, 0, 0, 0], [0, 2, 0, 0], [1, 0, 0, ]] answer_list = [((0, 3), (2, 1))] self.assertEqual(Window.must_turn_cell([], 0, 3, True, field), answer_list)
def test_must_turn_cell16(self): field = Field(4, "RU") field.field = \ [[0, 0, 0, 0], [0, 0, 0, 2], [0, 0, 1, 0], [0, 0, 0, ]] answer_list = [((3, 1), (1, 3))] self.assertEqual(Window.must_turn_cell([], 3, 1, False, field), answer_list)
def test_must_turn_cell9(self): field = Field(4, "RU") field.field = \ [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 4, 0], [0, 0, 0, 1]] answer_list = [((3, 3), (1, 1))] self.assertEqual(Window.must_turn_cell([], 3, 3, True, field), answer_list)
def test_must_turn_cell10(self): field = Field(4, "RU") field.field = \ [[2, 0, 0, 0], [0, 3, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] answer_list = [((0, 0), (2, 2))] self.assertEqual(Window.must_turn_cell([], 0, 0, False, field), answer_list)
def test_must_turn_cell2(self): field = Field(4, "RU") field.field = \ [[0, 0, 0, 0], [0, 2, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]] answer_list = [((2, 2), (0, 0))] self.assertEqual(Window.must_turn_cell([], 2, 2, True, field), answer_list)
def updateOpenWindows(self): self.open_windows=Window.get_open_windows() try: if self.conf["size"]!=self.HALF_OPEN_POS: XlibStuff.fix_window(self.winId(),self.HALF_OPEN_POS+5,0,0,0) except: pass self.update() QtGui.QApplication.processEvents() Config.check_dict(self.conf)
def __reset(self): """ Resets the game and all its objects :return: """ self.map = None self.mapFile = self.__loadMap() self.window = Window(len(self.mapFile[0]) * BaseTile.WIDTH, len(self.mapFile) * BaseTile.HEIGHT) self.renderMenu = True self.enemies.empty()
def wheelEvent(self,e): Window.activateFakewin(self.fakewin.winId()) if self.activity == 'apps': value= int(e.delta()/120) max_pages=math.trunc((len(self.allApps)-1)/self.apps_per_page) if value>0 and self.app_page_state>0: self.app_page_state-=1 if value<0 and self.app_page_state<max_pages: self.app_page_state+=1 self.update() QtGui.QApplication.processEvents() if self.activity == 'files': value= int(e.delta()/120) max_pages=math.trunc(len(self.Files.all())/self.apps_per_page) if value>0 and self.files_page_state>0: self.files_page_state-=1 if value<0 and self.files_page_state<max_pages: self.files_page_state+=1 self.update() QtGui.QApplication.processEvents()
def onModuleLoad(self): self.singleton = self topPanel = TopPanel() rightPanel = VerticalPanel() self.mailDetail = MailDetail() self.shortcuts = Shortcuts() topPanel.setWidth("100%") # MailList uses Mail.get() in its constructor, so initialize it after # 'singleton'. mailList = MailList(self.singleton) mailList.setWidth("100%") # Create the right panel, containing the email list & details. rightPanel.add(mailList) rightPanel.add(self.mailDetail) mailList.setWidth("100%") self.mailDetail.setWidth("100%") # Create a dock panel that will contain the menu bar at the top, # the shortcuts to the left, and the mail list & details taking the rest. outer = DockPanel() outer.add(topPanel, DockPanel.NORTH) outer.add(self.shortcuts, DockPanel.WEST) outer.add(rightPanel, DockPanel.CENTER) outer.setWidth("100%") outer.setSpacing(4) outer.setCellWidth(rightPanel, "100%") # Hook the window resize event, so that we can adjust the UI. #FIXME need implementation # Window.addWindowResizeListener(this) #Window.addWindowResizeListener(self) # Get rid of scrollbars, and clear out the window's built-in margin, # because we want to take advantage of the entire client area. Window.enableScrolling(False) Window.setMargin("0px") # Finally, add the outer panel to the RootPanel, so that it will be # displayed. #RootPanel.get().add(outer) # FIXME get# RootPanel().add(outer) RootPanel().add(Logger()) # Call the window resized handler to get the initial sizes setup. Doing # this in a deferred command causes it to occur after all widgets' sizes # have been computed by the browser. # FIXME - need implementation# # DeferredCommand.add(onWindowResized(Window.getClientWidth(), Window.getClientHeight())) self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())
def __init__(self): super(GLTD, self).__init__() self.totalEnemies = 1 self.window = Window() self.window.addActor(GridActor(0, 0, 600, 600)) self.window.board = BoardActor(0, 0, 600, 600) self.window.addActor(self.window.board) self.window.addActor(masterParticleClock) # TODO: unmessify. IMPORTANT #anim = Animation(20, [], LINEAR) #self.px = 10.0 #self.py = 10 #anim.onCompletion(self.createNewParticles) #anim.loop = True #self.window.addAnimation(anim) #anim.start() anim = Animation(1864, [], LINEAR) anim.onCompletion(self.createNewEnemy) anim.loop = True self.window.addAnimation(anim) anim.start() #tower = RedL1TowerActor(4,7) #self.window.addTower(tower) #tower.start() # #tower = RedL1TowerActor(10,5) #tower.range = 150 #tower.reloadSpeed = 300 #tower.damage = 1000 #tower.shake = 2 #self.window.addTower(tower) #tower.start() towerChooser = TowerChooser(600, 300, 200, 300) self.window.addActor(towerChooser) tower = RedL1TowerActor(0, 0) tower.active = False tower.x = tower.y = 40.0 towerChooser.addActor(tower) glutMainLoop()
def onModuleLoad(self): slot = RootPanel("calendar") Window.alert("slot:" + slot) if slot: calendar = SchoolCalendarWidget(15) Window.alert(len(slot.children)) Window.alert(slot.children) slot.add(calendar) slot = RootPanel("days") if slot: filterWidget = DayFilterWidget(calendar) slot.add(filterWidget)
def __init__(self): """ The Constructor of the Controller """ self.themeFactory = None self.mapFile = self.__loadMap() self.map = None self.window = Window(len(self.mapFile[0]) * BaseTile.WIDTH, len(self.mapFile) * BaseTile.HEIGHT) self.jukebox = Jukebox() self.player = None self.clock = pygame.time.Clock() self.enemies = pygame.sprite.RenderPlain() self.bullets = pygame.sprite.RenderPlain() self.walls = pygame.sprite.RenderPlain() self.pathfinder = Pathfinder() self.players = pygame.sprite.RenderPlain() self.collisionDetector = None self.renderMenu = True self.userInterface = None
class Controller(object): """ The Controller of the game """ def __init__(self): """ The Constructor of the Controller """ self.themeFactory = None self.mapFile = self.__loadMap() self.map = None self.window = Window(len(self.mapFile[0]) * BaseTile.WIDTH, len(self.mapFile) * BaseTile.HEIGHT) self.jukebox = Jukebox() self.player = None self.clock = pygame.time.Clock() self.enemies = pygame.sprite.RenderPlain() self.bullets = pygame.sprite.RenderPlain() self.walls = pygame.sprite.RenderPlain() self.pathfinder = Pathfinder() self.players = pygame.sprite.RenderPlain() self.collisionDetector = None self.renderMenu = True self.userInterface = None def start(self): """ Starts the game by "starting" the infinite loop :return: """ self.jukebox.playSound("menu") while True: # PROCESS INPUT self.__handle_events() # LOGIC STUFF if self.renderMenu: self.jukebox.playSound("menu") self.__renderMenu() elif self.player.life <= 0: self.jukebox.playSound("dead") self.userInterface.drawLostScreen() else: self.jukebox.playSound("game") if self.player is not None: self.player.move() if pygame.time.get_ticks() % (1000 / self.map.amountHorizontal) is 0: self.__spawnEnemy() self.enemies.update(self.player, self.map) self.bullets.update() self.collisionDetector.checkCollisions() # DRAW EVERYTHING self.userInterface.draw() self.__drawWorld() pygame.display.flip() self.clock.tick(30) def __drawWorld(self): """ Draws all game objects """ self.map.sprites.draw(self.window.screen) self.players.draw(self.window.screen) self.enemies.draw(self.window.screen) self.bullets.draw(self.window.screen) self.userInterface.draw() def __loadMap(self): """ Loads and generates the map :return: the generated map """ mapGenerator = MapGenerator() return mapGenerator.generateMap() def __initPlayer(self): """ Builds the Player :return: the player object """ tile = self.map.getWalkableTile() player = self.themeFactory.createThemeElement("pl") player.setCoordinates(tile.row, tile.col) self.players.add(player) return player def __spawnEnemy(self): """ Spawns the enemy at a random spawn point """ tile = self.map.getSpawnPoint() enemy = Enemy() enemy.setCoordinates(tile.row, tile.col) self.enemies.add(enemy) def __renderMenu(self): """ Renders the main menu """ self.window.renderMenu() def __initGameTheme(self): """ Sets up all needed objects to start the game :return: """ self.map = Map(self.mapFile, self.themeFactory) self.player = self.__initPlayer() self.userInterface = UserInterface(self.window.screen, self.player) self.walls.add(self.map.wallTiles) self.collisionDetector = CollisionDetector(self.players, self.enemies, self.bullets, self.walls) def __reset(self): """ Resets the game and all its objects :return: """ self.map = None self.mapFile = self.__loadMap() self.window = Window(len(self.mapFile[0]) * BaseTile.WIDTH, len(self.mapFile) * BaseTile.HEIGHT) self.renderMenu = True self.enemies.empty() def __handle_events(self): """ Handles all occuring events (pygame events) :return: """ for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit(0) if event.type == KEYDOWN: if event.key == pygame.K_SPACE: self.player.shotSound.play() bullet = Bullet(self.map.getTileByCoords(self.player.rect.center), self.player.viewingDirection) self.bullets.add(bullet) if event.key == pygame.K_p: if self.player.life <= 0: self.__reset() pressedKeys = pygame.key.get_pressed() if pressedKeys[pygame.K_ESCAPE]: pygame.quit() sys.exit(0) if self.renderMenu is False: if pressedKeys[pygame.K_UP]: self.player.setTarget(self.map.getNextTile(self.player.rect.center, ViewingDirection.NORTH)) if pressedKeys[pygame.K_DOWN]: self.player.setTarget(self.map.getNextTile(self.player.rect.center, ViewingDirection.SOUTH)) if pressedKeys[pygame.K_RIGHT]: self.player.setTarget(self.map.getNextTile(self.player.rect.center, ViewingDirection.EAST)) if pressedKeys[pygame.K_LEFT]: self.player.setTarget(self.map.getNextTile(self.player.rect.center, ViewingDirection.WEST)) if self.renderMenu is True: if pressedKeys[pygame.K_1]: self.themeFactory = ZombieThemeFactory() self.__initGameTheme() self.renderMenu = False if pressedKeys[pygame.K_2]: self.themeFactory = GrasslandsThemeFactory() self.__initGameTheme() self.renderMenu = False
def setPixelQuickly(self, id, x, y, color): return pmSetPixelQuickly(int(id), int(x), int(y), color) def openImage(self, id, filename): return pmOpenImage(int(id), filename) def newImage(self, id, title, width, height, r, g, b): return pmNewImage(id, title, int(width), int(height), int(r), int(g), int(b)) def getImageWidth(self, id): return pmGetImageWidth(int(id)) def getImageHeight(self, id): return pmGetImageHeight(int(id)) def refresh(self, id): return pmUpdateDisplay(int(id)) Window.init(PixelMathBridge()) size = Vec2(100,100) canvas = Window(size) pmOpenImage(canvas.id,"archery.jpg") def neighboring(position): yield position.plus(Vec2(-1,-1)) yield position.plus(Vec2(-1,0)) yield position.plus(Vec2(-1,1)) yield position.plus(Vec2(0,-1)) #yield position.plus(Vec2(0,0)) yield position.plus(Vec2(0,1)) yield position.plus(Vec2(1,-1)) yield position.plus(Vec2(1,0))
import java.awt.Color as Color import Vec2 import PixelMathAbstractionInterface class PixelMathBridge(PixelMathAbstractionInterface): def getPixelQuickly(self, id, x, y): return pmGetPixelQuickly(int(id), int(x), int(y)) def setPixelQuickly(self, id, x, y, color): return pmSetPixelQuickly(int(id), int(x), int(y), color) def openImage(self, id, filename): return pmOpenImage(int(id), filename) def newImage(self, id, title, width, height, r, g, b): return pmNewImage(id, title, int(width), int(height), int(r), int(g), int(b)) def getImageWidth(self, id): return pmGetImageWidth(int(id)) def getImageHeight(self, id): return pmGetImageHeight(int(id)) def refresh(self, id): return pmUpdateDisplay(int(id)) Window.init(PixelMathBridge())
def setPixelQuickly(self, id, x, y, color): return pmSetPixelQuickly(int(id), int(x), int(y), color) def openImage(self, id, filename): return pmOpenImage(int(id), filename) def newImage(self, id, title, width, height, r, g, b): return pmNewImage(id, title, int(width), int(height), int(r), int(g), int(b)) def getImageWidth(self, id): return pmGetImageWidth(int(id)) def getImageHeight(self, id): return pmGetImageHeight(int(id)) def refresh(self, id): return pmUpdateDisplay(int(id)) Window.init(PixelMathBridge()) size = Vec2(600,600) canvas = Window(size) def inMandelbrotSet(c): z = 0 h = 0 for h in xrange(0, 100): z = z**2 + c if abs(z) > 2: break; if abs(z) >= 2: return -1 else:
def main(): #random.seed(0) #environment = Environment(gridSize=32, cellSize=10, terrainResolution=128) environment = Environment(gridSize=32, cellSize=10, terrainResolution=128) window = Window(environment) window.start()
def main(): w = Window() w.display()
def greet(sender): Window.alert("Hello, AJAX!")
def updateOpenWindows(self): self.open_windows=window.get_open_windows() self.update()
def mousePressEvent(self,e): x_m,y_m = e.x(),e.y() self.open_windows=window.get_open_windows() self.update() QtGui.QApplication.processEvents() if self.current_state=="open": if self.pos_x-self.SIZE<x_m<self.pos_x and self.move==False: self.close_it() ###app events if self.activity == "apps": max_apps= math.trunc(len(Apps.info(self.current_text))/self.apps_per_page)+1 ##Change Page for i in range(0,max_apps): btn_size = 20 x_pos = self.s_width/6-btn_size+(btn_size*i) if x_pos<x_m<x_pos+btn_size and 2<y_m<2+btn_size: self.app_page_state=i self.update() QtGui.QApplication.processEvents() ## launch apps for i, app in enumerate(Apps.info(self.current_text)): app_page = math.trunc(i/self.apps_per_page) if app_page==self.app_page_state: row_pos = math.trunc(i/self.apps_per_row) x_pos = self.ICON_SIZE*(i-(row_pos*self.apps_per_row))+30 y_pos = row_pos*self.ICON_SIZE+30-(app_page*(self.ICON_SIZE*self.apps_per_col)) if x_pos<x_m<(x_pos+self.ICON_SIZE) and y_pos<y_m<(y_pos+self.ICON_SIZE): print "It should launch: " + app["name"] + " with " + app["exec"] thread = Launch(parent=self) thread.app=app["exec"] thread.start() self.close_it() if self.activity == "files": if 10<x_m<40 and 10<y_m<40: l= self.Files.directory.split("/")[:-1][1:] new_dir='' for a in l: new_dir+='/' new_dir+=a if new_dir=='':new_dir='/' self.Files.directory=new_dir self.update() max_files= math.trunc(len(self.Files.all())/self.apps_per_page)+1 ##Change Page for i in range(0,max_files): btn_size = 20 x_pos = self.s_width/6-btn_size+(btn_size*i) if x_pos<x_m<x_pos+btn_size and 2<y_m<2+btn_size: self.files_page_state=i self.update() QtGui.QApplication.processEvents() ## launch apps for i, f in enumerate(self.Files.all()): app_page = math.trunc(i/self.apps_per_page) if app_page==self.files_page_state: row_pos = math.trunc(i/self.apps_per_row) x_pos = self.ICON_SIZE*(i-(row_pos*self.apps_per_row))+30 y_pos = row_pos*self.ICON_SIZE+30-(app_page*(self.ICON_SIZE*self.apps_per_col)) if x_pos<x_m<(x_pos+self.ICON_SIZE) and y_pos<y_m<(y_pos+self.ICON_SIZE): if f["type"]=="file": import webbrowser webbrowser.open(f["whole_path"]) elif f["type"]=="directory": self.Files.directory=f["whole_path"] self.update() QtGui.QApplication.processEvents() if self.activity=="star": blocks=self.conf['blocks'] all_rows=0 for i,b in enumerate(blocks): all_stuff = Config.get_from_block(b) row_num = math.trunc(len(all_stuff)/self.apps_per_row)+1 h=self.ICON_SIZE*all_rows+20 all_rows+=row_num for j, thing in enumerate(all_stuff): row_pos = math.trunc(j/self.apps_per_row) x_pos = self.ICON_SIZE*(j-(row_pos*self.apps_per_row))+40 y_pos = (row_pos*self.ICON_SIZE+20)+h if x_pos+15<x_m<x_pos+15+self.ICON_SIZE and y_pos+15<y_m<y_pos+15+self.ICON_SIZE: if thing['type']=='app': the_exec="" for a in Apps.info(''): if thing['value'] in a['name']: print "a" the_exec=a['exec'] thread = Launch(parent=self) thread.app=the_exec thread.start() print "Launching " , thing['value'], "with :",the_exec else: import webbrowser webbrowser.open(thing['value']) if self.current_state=="half_open": ##buttons if 0<x_m<self.HALF_OPEN_POS: if 0<y_m<self.ICO_TOP: self.activity="apps" self.current_text='' self.open_it() if self.ICO_TOP<y_m<self.ICO_TOP*2: self.activity="files" self.Files.directory=self.Files.default self.open_it() if self.ICO_TOP*2<y_m<self.ICO_TOP*3: self.activity="settings" self.settings_win.show() if self.ICO_TOP*3<y_m<self.ICO_TOP*4: self.activity="star" self.open_it() try: ####OFF WE GOOO! for i,a in enumerate(self.dock_apps): if self.OPEN_STATE_TOP+self.ICO_TOP*i+10<y_m<self.OPEN_STATE_TOP+self.ICO_TOP*(i+1)+10: print "It should launch: " + a["name"] + " with " + a["exec"] thread = Launch(parent=self) thread.app=a["exec"] thread.start() self.close_it() except KeyError: pass if self.s_height-self.ICO_TOP*2-20<y_m<self.s_height-self.ICO_TOP-20: ##open windows if self.open_state==False: if len(self.open_windows)>0: self.open_win.update_apps() self.open_win.show() self.open_state=True else:pass elif self.open_state==True: self.open_win.close() self.open_state=False if self.s_height-self.ICO_TOP*2-20>y_m<self.s_height-self.ICO_TOP-20: self.open_win.close() if self.s_height-self.ICO_TOP<y_m<self.s_height: sys.exit()
# -*- coding: utf-8 -*- from Window import * if __name__ == '__main__': a = Window() a.Main_Window() a.slots_for_base() time.sleep(10)
import Window if __name__ == "__main__": root = Window.main_gui() root.mainloop()
def setPixelQuickly(self, id, x, y, color): return pmSetPixelQuickly(int(id), int(x), int(y), color) def openImage(self, id, filename): return pmOpenImage(int(id), filename) def newImage(self, id, title, width, height, r, g, b): return pmNewImage(id, title, int(width), int(height), int(r), int(g), int(b)) def getImageWidth(self, id): return pmGetImageWidth(int(id)) def getImageHeight(self, id): return pmGetImageHeight(int(id)) def refresh(self, id): return pmUpdateDisplay(int(id)) Window.init(PixelMathBridge()) size = Vec2(500.0,500.0) canvas = Window(size) for pixel in canvas.pixels(): brightness = random.random() brightness /= 10 pixel.setColor(Color((int)(brightness*255),(int)(brightness*255),(int)(brightness*255))) canvas.refresh() pmSetPolar() pmSetFormula("if rho <100 then RGB(0,200,0) else source1(rho, theta)") pmSetDestination(canvas.id) pmCompute()
def __init__(self): self.__window = Window() self.__planets = self.createPlanetList() self.animate() self.__window.mainLoop()
def onClick(self, sender): Window.alert("object called")
#!/usr/bin/env python2 from Common import * from Image import * from Window import * window = Window("DanRTS", 720) believe = Image("believe.png") window.add(believe) while not done(): window.events() window.draw()
def onButtonClick(sender): Window.alert("function called")
class SolarSystem: """ Defines the speed of the simulation """ SPEED = 1; """ Function: Initialisation. Description: This initialises the solar system class by creating all of the arguments and adding them to a list. Args: self: Self from class. """ def __init__(self): self.__window = Window() self.__planets = self.createPlanetList() self.animate() self.__window.mainLoop() """ Function: createPlanetList Description: This creates a list of all of the planets and then appends them to an array Args: self: Self from class. Returns: planets: A list of the planets. """ def createPlanetList(self): sun = Planet(self.__window, "Sun", 330000, 0, 0, 5, "yellow", 0, 0, 0) mercury = Planet(self.__window, "Mercury", 0.06, 0.387, 0, 5, "grey", 0.3871, 0.2056, 87.969) venus = Planet(self.__window, "Venus", 0.82, 0.723, 0, 5, "orange", 0.7233, 0.0068, 224.701) earth = Planet(self.__window, "Earth", 1, 1, 0, 5, "blue", 1.000, 0.0167, 365.256) mars = Planet(self.__window, "Mars", 0.11, 1.524, 0, 5, "gold2", 1.5273, 0.0934, 686.98) jupiter = Planet(self.__window, "Jupiter", 317.8, 5.203, 0, 5, "thistle4", 5.2028, 0.0484, 4329.63) saturn = Planet(self.__window, "Saturn", 95.2, 9.582, 0, 5, "khaki2", 9.5388, 0.0542, 10751.805) uranus = Planet(self.__window, "Uranus", 14.6, 19.201, 0, 5, "skyblue", 19.1914, 0.0472, 30664.015) neptune = Planet(self.__window, "Neptune", 17.2, 30.047, 0, 5, "royalblue3", 30.0611, 0.0086, 60148.35) planets = [] planets.append(sun) planets.append(mercury) planets.append(venus) planets.append(earth) planets.append(mars) planets.append(jupiter) planets.append(saturn) planets.append(uranus) planets.append(neptune) return planets """ Function: animate Description: This is used to run the actual animation of the solar system. Every iteration it clears the screen and then draws each of the planets. Args: self: Self from class. """ def animate(self): self.__window.clear() for planet in self.__planets: planet.animate() self.__window.after(self.SPEED, self.animate)