def __init__(self, buoy): MapPointThreaded.__init__(self) self.__buoy = buoy self.__url = "http://www.ndbc.noaa.gov/data/latest_obs/%s.rss" % buoy self.set_icon(utils.get_icon("\\N"))
def add_monitored_item(self, index, node): variable_name = node.get_display_name().Text descriptions = node.get_references(ua.ObjectIds.Aggregates, ua.BrowseDirection.Inverse, ua.NodeClass.Object, True) parent_node = node while not descriptions: parent_node = parent_node.get_parent() descriptions = parent_node.get_references(ua.ObjectIds.Aggregates, ua.BrowseDirection.Inverse, ua.NodeClass.Object, True) parent_nodeid = descriptions[0].NodeId if parent_nodeid in self.opc_ua_client.custom_objects: custom_type = self.opc_ua_client.custom_objects[parent_nodeid] icon = get_icon(custom_type) else: icon = "icons/object.svg" row = [QStandardItem(QIcon(icon), descriptions[0].DisplayName.Text), QStandardItem(variable_name), QStandardItem("No Data yet"), QStandardItem("")] row[0].setData(node) self.model.appendRow(row) self.subscribed_nodes.append(node) try: self.opc_ua_client.create_monitored_items(node, index) row[0].setData(self.window.get_monitored_item_tooltip(), Qt.ToolTipRole) self.model.sort(0, Qt.AscendingOrder) self._color_rows() except Exception as ex: self.window.show_error(ex) idx = self.model.indexFromItem(row[0]) self.model.takeRow(idx.row()) self.subscribed_nodes.remove(node) raise
async def on_message(self, message: discord.Message, trigger: str, args: list): if not args: return where, what = re.match(rf'{self.bot.prefix}{trigger}\s(\w+)\s?(.+)?', message.content).groups() if where in ('g', 'guild'): item = message.guild else: if where in ('cat', 'category'): items = message.guild.categories elif where in ('ch', 'channel'): items = message.guild.channels elif where in ('vc', 'voice'): items = message.guild.voice_channels elif where in ('r', 'role'): items = message.guild.roles elif where in ('u', 'user'): items = message.guild.members else: return item = utils.find(lambda i: i.name.lower() == what.lower(), items) if item: response = utils.create_embed( title=f'{item.name}', description=f'{item.id}', colour=utils.get_colour(item), icon=utils.get_icon(item) ) await message.channel.send(embed=response)
def __init__(self, zone, name, x, y, items=[]): self.zone = zone self.name = name self.icon = get_icon(self.name) self.x = x self.y = y self.just_moved = True self.temperature = 20 self.inv = Inventory(self, items)
def _init_toolbar(self): super(CustomNavigationToolbar, self)._init_toolbar() for text, tooltip_text, image_file, callback in self.custom_toolitems: a = self.addAction( utils.get_icon(image_file), text, getattr(self, callback) ) if tooltip_text is not None: a.setToolTip(tooltip_text)
def build_gui(self): self.SetMinSize((250, 300)) # icons self.SetIcon(utils.get_icon('todo')) self.tray_icon = wx.TaskBarIcon() self.tray_icon.SetIcon(utils.get_icon('tray16')) self.tray_icon.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.OnDeIconize) self.tray_icon.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.OnTrayMenu) # add a menu bar self.statusbar = self.CreateStatusBar() self.SetMenuBar(menus.buildMenuBar(self, self.get_menus())) self.GetMenuBar().FindItemById(wx.ID_OPEN).Enable(False) self.GetMenuBar().FindItemById(wx.ID_CLOSE).Enable(False) # build a menu for the tray icon self.tray_menu = wx.Menu() self.tray_menu.Append(wx.ID_NEW, 'New task...') self.tray_menu.Append(wx.ID_ABOUT, 'About PyTodo...') self.tray_menu.Append(wx.ID_EXIT, 'Quit') # add a toolbar self.toolbar = self.CreateToolBar(style=wx.TB_HORIZONTAL|wx.NO_BORDER) self.toolbar.AddSimpleTool(wx.ID_NEW, utils.get_bmp('add'), 'Add New Task', 'Create a new task') self.toolbar.AddSimpleTool(wx.ID_OPEN, utils.get_bmp('edit'), 'Edit Task', 'Edit the selected task') self.toolbar.AddSimpleTool(wx.ID_CLOSE, utils.get_bmp('remove'), 'Remove Task', 'Remove the selected task') self.toolbar.AddSeparator() self.toolbar.AddControl(wx.StaticText(self.toolbar, label='Filter: ')) self.filter = wx.TextCtrl(self.toolbar) self.toolbar.AddControl(self.filter) # disable the edit and remove buttons by default self.toolbar.EnableTool(wx.ID_OPEN, False) self.toolbar.EnableTool(wx.ID_CLOSE, False) # task list self.tasks = wx.TreeCtrl(self, style=wx.BORDER_SUNKEN|wx.TR_HIDE_ROOT) self.root = self.tasks.AddRoot('All Tasks')
def do_dprs_calculator(initial=""): def ev_sym_changed(iconsel, oversel, icons): oversel.set_sensitive(icons[iconsel.get_active()][1][0] == "\\") d = inputdialog.FieldDialog(title=_("DPRS message")) msg = gtk.Entry(13) overlays = [chr(x) for x in range(ord(" "), ord("_"))] cur = initial if cur and cur[-3] == "*" and cur[3] == " ": msg.set_text(cur[4:-3]) dsym = cur[:2] deficn = gps.DPRS_TO_APRS.get(dsym, "/#") defovr = cur[2] if defovr not in overlays: print "Overlay %s not in list" % defovr defovr = " " else: deficn = "/#" defovr = " " icons = [] for sym in sorted(gps.DPRS_TO_APRS.values()): icon = get_icon(sym) if icon: icons.append((icon, sym)) iconsel = miscwidgets.make_pixbuf_choice(icons, deficn) oversel = miscwidgets.make_choice(overlays, False, defovr) iconsel.connect("changed", ev_sym_changed, oversel, icons) ev_sym_changed(iconsel, oversel, icons) d.add_field(_("Message"), msg) d.add_field(_("Icon"), iconsel) d.add_field(_("Overlay"), oversel) r = d.run() aicon = icons[iconsel.get_active()][1] mstr = msg.get_text().upper() over = oversel.get_active_text() d.destroy() if r != gtk.RESPONSE_OK: return dicon = gps.APRS_TO_DPRS[aicon] callsign = mainapp.get_mainapp().config.get("user", "callsign") string = "%s%s %s" % (dicon, over, mstr) check = gps.DPRS_checksum(callsign, string) return string + check
def add_user(self): """Search new users via central server.""" user_id = self.search_idLE.text() if not utils.is_valid_id(user_id): QMessageBox.information(None, 'warning', 'Invalid ID!', QMessageBox.Ok) return if user_id == self.me_user.user_id: QMessageBox.information(None, 'warning', 'Why searching for yourself?', QMessageBox.Ok) return if self.get_user_via_id(user_id) is not None: QMessageBox.information(None, 'info', 'User is already your friend!', QMessageBox.Ok) return # check whether online result = self.central_server_connector.search_user(user_id) if result == 'n': QMessageBox.information(None, 'info', 'User not online!', QMessageBox.Ok) return # update user if self.use_my_central_server: new_user = User(user_id=user_id, name=None, ip=result[0], port=result[1], icon=utils.get_icon()) else: new_user = User(user_id=user_id, name=None, ip=result, port=config.GENERAL_PORT, icon=utils.get_icon()) self.update_user(new_user, sock=None) self.search_idLE.setText('')
def play(camera_number, show_controls=None): """ Function to call to play the IP Camera feed. Determines if controls are shown or not. """ camera = Camera(camera_number) if camera.Connected(monitor): if show_controls == None: show_controls = False # Generic IP Cameras default without Controls if camera._type != GENERIC_IPCAM: # Foscam Cameras default with Controls show_controls = True if show_controls: player = CameraControlsWindow(camera, monitor) player.start() else: url = camera.getStreamUrl(0) name = settings.getCameraName(camera.number) utils.log( 2, 'Camera %s :: Name: %s; Url: %s' % (camera.number, name, url)) listitem = xbmcgui.ListItem() listitem.setInfo(type='Video', infoLabels={'Title': name}) listitem.setArt({'thumb': utils.get_icon(camera.number)}) utils.log( 1, 'Camera %s :: *** Playing Fullscreen *** URL: %s' % (camera.number, url)) player = xbmc.Player() player.play(url, listitem) if monitor.resume_previous_file(): while not player.isPlaying() and not monitor.stopped( ) and not monitor.abortRequested(): monitor.waitForAbort(.5) while player.isPlaying( ) and not monitor.stopped() and not monitor.abortRequested(): monitor.waitForAbort(.5) monitor.maybe_resume_previous() else: utils.log( 3, 'Camera %s :: Camera is not configured correctly' % camera.number) utils.notify('Camera %s not configured correctly' % camera.number)
def update_user(self, new_user, sock=None): """Add a new user item to self.friendsLW.""" self.all_users[new_user.user_id] = copy.deepcopy(new_user) new_user_item = QListWidgetItem(utils.get_icon(), new_user.user_id + ' (online)') self.friendsLW.addItem(new_user_item) # update private chat new_private_chat = PrivateChat(self.me_user, copy.deepcopy(new_user), self.normal_chat_signals, self.video_chat_signals, sock=sock) new_private_chat.start() self.update_chat(new_private_chat)
def add_item(self, desc, parent=None, node=None): dname = bname = "No Value" if desc.DisplayName: dname = desc.DisplayName.to_string() if desc.BrowseName: bname = desc.BrowseName.to_string() nodeid = desc.NodeId.to_string() item = [ QStandardItem(dname), QStandardItem(bname), QStandardItem(nodeid) ] if desc.NodeClass == ua.NodeClass.Object: if desc.TypeDefinition == ua.TwoByteNodeId( ua.ObjectIds.FolderType): item[0].setIcon(QIcon("icons/folder.svg")) else: try: object_type = self.custom_objects[desc.NodeId] icon = get_icon(object_type) except KeyError: icon = "icons/object.svg" item[0].setIcon(QIcon(icon)) elif desc.NodeClass == ua.NodeClass.Variable: if desc.TypeDefinition == ua.TwoByteNodeId( ua.ObjectIds.PropertyType): item[0].setIcon(QIcon("icons/property.svg")) else: item[0].setIcon(QIcon("icons/variable.svg")) elif desc.NodeClass == ua.NodeClass.Method: item[0].setIcon(QIcon("icons/method.svg")) elif desc.NodeClass == ua.NodeClass.ObjectType: item[0].setIcon(QIcon("icons/objecttype.svg")) elif desc.NodeClass == ua.NodeClass.VariableType: item[0].setIcon(QIcon("icons/variabletype.svg")) elif desc.NodeClass == ua.NodeClass.DataType: item[0].setIcon(QIcon("icons/datatype.svg")) elif desc.NodeClass == ua.NodeClass.ReferenceType: item[0].setIcon(QIcon("icons/referencetype.svg")) if node: item[0].setData(node, Qt.UserRole) else: parent_node = parent.data(Qt.UserRole) item[0].setData(Node(parent_node.server, desc.NodeId), Qt.UserRole) if parent: return parent.appendRow(item) else: return self.appendRow(item)
def __init__(self, name, x=0, y=0): self.name = name self.x = x self.y = y self.mass = 0 self.poisonous = False self._temperature = 15 self.icon = get_icon(self.name) self.slot = '' self.broken = False self.destroyed = False if 'potion' in name: self.mass = 0.8 self._quantity = 3 if 'green potion' in name: self.poisonous = True elif 'green puddle' in name: self._quantity = 3 elif 'poison cloud' in name: self._duration = 10 elif 'flask' in name: self.mass = 0.2 self._quantity = 0 elif 'scroll' in name: self._quantity = 0 if 'blank scroll' not in name: self._quantity = 1 elif 'meal' in name: self.mass = 0.1 self._quantity = 1 elif 'sweater' in name: self.mass = 1 self.slot = 'chest' elif 'barrel top' in name: self.mass = 3 self.slot = 'weapons/shields' elif 'stick' in name: self.mass = 0.3 self.slot = 'weapons/shields' elif 'torch' in name: self.mass = 0.3 self._duration = 50 self.slot = 'weapons/shields' elif 'boots' in name: self.mass = 0.7 self.slot = 'feet'
def graph(): if not session.has_key('user'): return redirect(url_for('login')) prices=utils.get_market_y() sadp=prices["sad"][len(prices["sad"])-1] boredp=prices["bored"][len(prices["bored"])-1] lovep=prices["love"][len(prices["love"])-1] tiredp=prices["tired"][len(prices["tired"])-1] happyp=prices["happy"][len(prices["happy"])-1] sickp=prices["sick"][len(prices["sick"])-1] madp=prices["mad"][len(prices["mad"])-1] boredi=utils.get_icon("bored") sadi=utils.get_icon("sad") lovei=utils.get_icon("love") tiredi=utils.get_icon("tired") happyi=utils.get_icon("happy") sicki=utils.get_icon("sick") madi=utils.get_icon("mad") if request.method == "GET": return render_template("graph.html",bored="bored",boredp=boredp,lovep=lovep,tiredp=tiredp,happyp=happyp,sickp=sickp,madp=madp,sadp=sadp,boredi=boredi[0],sadi=sadi[0],lovei=lovei[0],tiredi=tiredi[0],happyi=happyi[0],sicki=sicki[0],madi=madi[0],boredip=boredi[1],loveip=lovei[1],tiredip=tiredi[1],happyip=happyi[1],sickip=sicki[1],madip=madi[1],sadip=sadi[1]); if request.method == "POST": d=session['user'] value=request.form["button"] value=value.split(" ") if (str(value[1])=="buy"): text=request.form[str(value[0])] if (text!=""): try: text=int(text) holder=utils.buy_stock(d,str(value[0]),int(text)) except Exception: holder=False if (str(value[1])=="sell"): text=request.form[str(value[0])+" sold"] if (text!=""): try: text=int(text) holder=utils.sell_stock(d,str(value[0]),int(text)) except Exception: holder=False if (text=="" or holder == False): return redirect(url_for("crash")) else: return redirect(url_for("transact")) return render_template("graph.html",bored="bored",boredp=boredp,lovep=lovep,tiredp=tiredp,happyp=happyp,sickp=sickp,madp=madp,sadp=sadp);
def transact(): if request.method == "GET": prices=utils.get_market_y() sadp=prices["sad"][len(prices["sad"])-1] boredp=prices["bored"][len(prices["bored"])-1] lovep=prices["love"][len(prices["love"])-1] tiredp=prices["tired"][len(prices["tired"])-1] happyp=prices["happy"][len(prices["happy"])-1] sickp=prices["sick"][len(prices["sick"])-1] madp=prices["mad"][len(prices["mad"])-1] boredi=utils.get_icon("bored") sadi=utils.get_icon("sad") lovei=utils.get_icon("love") tiredi=utils.get_icon("tired") happyi=utils.get_icon("happy") sicki=utils.get_icon("sick") madi=utils.get_icon("mad") return render_template("graph2.html",bored="bored",boredp=boredp,lovep=lovep,tiredp=tiredp,happyp=happyp,sickp=sickp,madp=madp,sadp=sadp,boredi=boredi[0],sadi=sadi[0],lovei=lovei[0],tiredi=tiredi[0],happyi=happyi[0],sicki=sicki[0],madi=madi[0],boredip=boredi[1],loveip=lovei[1],tiredip=tiredi[1],happyip=happyi[1],sickip=sicki[1],madip=madi[1],sadip=sadi[1]);
def multithreaded_update(indicator): # initial data download pushes_list = bullet.get_pushes() GLib.idle_add(menu.update_list,pushes_list) while True: try: p = bullet.socket_check(ws) except: ws = bullet.socket_connect() p = bullet.socket_check(ws) # osd(APPINDICATOR_ID, APPINDICATOR_ID, "Has started", ICON) print p if p['type'] == 'tickle': if p['subtype'] == 'push': pushes_list = bullet.get_pushes() GLib.idle_add(menu.update_list,pushes_list) if pushes_list[0]['active']: osd(APPINDICATOR_ID, pushes_list[0]['title'], pushes_list[0]['body']) elif p['type'] == 'push': title = assign_from_json(p['push'],('title', 'application_name'), APPINDICATOR_ID) body = assign_from_json(p['push'], ('body', 'type'), "Unresolved") try: icon = p['push']['icon'] osd(APPINDICATOR_ID, title, body, get_icon(icon, pwd()+'static/')) except: pass try: bullet.reply_to_number = p['push']['conversation_iden'] bullet.reply_to_name = p['push']['title'] bullet.reply_to_message = p['push']['body'] indicator.set_status(AppIndicator3.IndicatorStatus.ATTENTION) except: pass GLib.idle_add(menu.append_item, p['push']) time.sleep(4)
def play(camera_number, show_controls = None): """ Function to call to play the IP Camera feed. Determines if controls are shown or not. """ camera = Camera(camera_number) if camera.Connected(monitor): if show_controls == None: show_controls = False # Generic IP Cameras default without Controls if camera._type != GENERIC_IPCAM: # Foscam Cameras default with Controls show_controls = True if show_controls: player = CameraControlsWindow(camera, monitor) player.start() else: url = camera.getStreamUrl(0) name = settings.getCameraName(camera.number) utils.log(2, 'Camera %s :: Name: %s; Url: %s' %(camera.number, name, url)) listitem = xbmcgui.ListItem() listitem.setInfo(type = 'Video', infoLabels = {'Title': name}) listitem.setArt({'thumb': utils.get_icon(camera.number)}) utils.log(1, 'Camera %s :: *** Playing Fullscreen *** URL: %s' %(camera.number, url)) player = xbmc.Player() player.play(url, listitem) if monitor.resume_previous_file(): while not player.isPlaying() and not monitor.stopped() and not monitor.abortRequested(): monitor.waitForAbort(.5) while player.isPlaying() and not monitor.stopped() and not monitor.abortRequested(): monitor.waitForAbort(.5) monitor.maybe_resume_previous() else: utils.log(3, 'Camera %s :: Camera is not configured correctly' %camera.number) utils.notify('Camera %s not configured correctly' %camera.number)
def __init__(self, path, x, y, color, name): # path to app (file) and name of the app self.path = Path(path) self.name = self.path.name if name is None else name self.old_name = self.name # class variables for position and movement self.x, self.y = x, y self.old_x, self.old_y = x, y self.offset_x, self.offset_y = 0, 0 # class variables for state of this app self.keep = True self.dragging = False self.options_opened = False self.renaming = False # class variables for various font, color, and special effects self.font = pg.font.Font(APP_FONT, APP_FONTSIZE) self.color_idx = color self.text_color = pg.Color(*COLOR_PAL[color]) self.icon = get_icon(path, "large") # instances that make up an App instance self.options_menu = AppOptionsMenu(self) self.rect = pg.Rect(x, y, 32, 32) self.text_surface = self.font.render(self.name, True, self.text_color)
def icon(self): pStore = self.__endpoint.OpenPropertyStore(STGM_READ) # try: return get_icon(pStore.GetValue(DEVPKEY_DeviceClass_IconPath))
def log_in(self): """User log in.""" self.use_my_central_server = self.log_in_win.use_my_central_serverCB.isChecked( ) config.MY_IP = socket.gethostbyname(socket.gethostname()) user_id = self.log_in_win.idLE.text() if not utils.is_valid_id(user_id): QMessageBox.information(None, 'warning', 'Invalid ID!', QMessageBox.Ok) return password = self.log_in_win.pswLE.text() # connect to central server if self.use_my_central_server: self.central_server_connector = \ central_server_connector.MyCentralServerConnector( config.MY_CENTRAL_SERVER_IP, config.MY_CENTRAL_SERVER_PORT) else: self.central_server_connector = \ central_server_connector.CentralServerConnector( config.CENTRAL_SERVER_IP, config.CENTRAL_SERVER_PORT) self.central_server_connector.connect() if not self.central_server_connector.is_connect: QMessageBox.information(None, 'warning', 'Cannot connect to central server!', QMessageBox.Ok) del self.central_server_connector self.central_server_connector = None return # user log in if self.use_my_central_server: self.central_server_connector.log_in(user_id, password, config.GENERAL_PORT) else: self.central_server_connector.log_in(user_id, password) if self.central_server_connector.is_log_in: QMessageBox.information(None, 'info', 'Log in successfully!', QMessageBox.Ok) else: QMessageBox.information(None, 'warning', 'Password error!', QMessageBox.Ok) del self.central_server_connector self.central_server_connector = None return self.log_in_win.idLE.setText('') self.log_in_win.pswLE.setText('') self.log_in_win.hide() # update my info self.me_user = User(user_id=user_id, name=None, ip=config.MY_IP, port=config.GENERAL_PORT, icon=utils.get_icon()) self.show() self.init() # update port information because default port maybe invalid if self.use_my_central_server: self.central_server_connector.log_in(user_id, password, self.me_user.port)
def set_icon_from_aprs_sym(self, symbol): self.set_icon(utils.get_icon(symbol)) self._aprs_sym = symbol
""" Show a silly little about box for the program. """ description = """%s is a pet project written by Josh VanderLinden using Python, wxPython, and MetaKit. Josh created this program mostly just for fun, but also to learn more about the three things mentioned in the last sentence.""" % APP_TITLE try: about = wx.AboutDialogInfo() except AttributeError, err: # older version of python wx.MessageBox(description, 'About This Program', wx.OK|wx.ICON_INFORMATION) else: about.SetIcon(utils.get_icon('tray')) about.SetName(APP_TITLE) about.SetVersion(APP_VERSION) about.SetDescription(description) about.SetCopyright("Copyright 2008 Josh VanderLinden") about.SetDevelopers(["Josh VanderLinden"]) about.SetWebSite('http://code.google.com/p/py-todo/') wx.AboutBox(about) def OnClose(self, event): """ Event handler to catch the signal to close the program and send it to the system tray. """ self.OnIconize(event, True)
def __init__(self, site): MapPointThreaded.__init__(self) self.__site = site self.__have_site = False self.set_icon(utils.get_icon("/w"))
def icon(self): return get_icon(self.__session.GetIconPath())
def handle_receive_message(self, sock, address): """Handle received message, which maybe text, image or file. This function will be called in multi-threading! """ ip, _ = address decoded_message = utils.decode_message(utils.recv_msg(sock)) if decoded_message is None: return chat_name, port, message_type, sender_id, _, _ = decoded_message # should only receive chat request or response in this function! try: assert message_type in [3, 4, 5, 6] except AssertionError: return if message_type == 3: # private chat request sender = self.get_user_via_id(sender_id) if sender is None: # other wants to start a private chat with me sender = User(user_id=sender_id, name=None, ip=ip, port=port, icon=utils.get_icon()) self.update_user(sender, sock=sock) else: # the user exists but still want a new chat # may because other deletes me and then add me back pass elif message_type == 4: # group chat request chat = self.get_chat_via_name(chat_name) if chat is None: # other wants to start a group chat with me user_ids = utils.get_id_from_chat_name(chat_name) group_users = {} for user_id in user_ids: if user_id == self.me_user.user_id: continue exist_user = self.get_user_via_id(user_id) if exist_user is None: result = self.central_server_connector.search_user( user_id) if self.use_my_central_server: exist_user = User(user_id=user_id, name=None, ip=result[0], port=result[1], icon=utils.get_icon()) else: exist_user = User(user_id=user_id, name=None, ip=result, port=config.GENERAL_PORT, icon=utils.get_icon()) else: exist_user = copy.deepcopy(exist_user) group_users[user_id] = exist_user chat = GroupChat(self.me_user, group_users, self.normal_chat_signals, group_leader_id=sender_id, sock=sock) chat.start() self.update_chat(chat) t = Thread(target=chat.init_socks, daemon=True) t.start() else: # group chat exists pass elif message_type == 5: # private chat response # actually useless pass elif message_type == 6: # group chat response # just update this sock to this group chat chat = self.get_chat_via_name(chat_name) if chat is None: return chat.update_server_sock(sock, sender_id)