コード例 #1
1
ファイル: main.py プロジェクト: kelvan/rgbw-app
 def set_leds(self, red, green, blue, white):
     print "turned off:", self.turned_off
     App.get_running_app().do_color_change \
         ( self.send_coap
         , self.idx
         , red, green, blue, white, self.status
         )
コード例 #2
0
ファイル: main.py プロジェクト: gandie/PlanetApp
    def build(self):

        self.settings_cls = SettingsWithSidebar

        game = PlanetGame(do_rotation=False,do_translation=False)
        # Settings come in as unicode!
        sunmass = float(App.get_running_app().config.get('planetapp','defaultsunmass'))
        game.sunmass = sunmass
        game.gravity = float(App.get_running_app().config.get('planetapp','gravity'))
        game.planetmass = float(App.get_running_app().config.get('planetapp','planetmass'))
        game.resetmass = float(App.get_running_app().config.get('planetapp','resetmass'))

        game.add_planet(True, (100,100), (0,0), sunmass, 10, (1,1,1))
        
        Clock.schedule_interval(game.update, 1.0 / 120.0)

        self.root = PlanetGameLayout()
        self.root.add_widget(game)
        

        b = Button(text="Reset",size_hint=(.3,.05),pos_hint={'x':.7,'y':0})
        b.bind(on_press=self.root.clear_planets)
        self.root.add_widget(b)
        b2 = SettingsButton(text="Settings",size_hint=(.3,.05),pos_hint={'x':.4,'y':0})
        self.root.add_widget(b2)

        b3 = Button(text="Next",size_hint=(.3,.05),pos_hint={'x':.1,'y':0})
        b3.bind(on_press=self.root.next_trajectory)
        self.root.add_widget(b3)
        self.root.reset_game()
コード例 #3
0
ファイル: main.py プロジェクト: danielmorman/momit-app
    def save_notes(self):

        App.get_running_app().tog.next()
        Window.release_all_keyboards()
        self.data2['user']=self.user.text
        self.data2['pass']=self.passwor.text
        Clock.schedule_once(self.login_m,1)
コード例 #4
0
    def on_touch_down(self, touch):
        """An override of ScatterPlane's on_touch_down.
           Used to determine the current selected widget and also emits,
           on_show_edit event.
        """

        if super(ScatterPlane, self).collide_point(*touch.pos) and not self.keyboard:
            win = EventLoop.window
            self.keyboard = win.request_keyboard(self._keyboard_released, self)
            self.keyboard.bind(on_key_down=self._on_keyboard_down)

        if super(ScatterPlane, self).collide_point(*touch.pos):
            if not self.dragging:
                self.touch = touch
                Clock.schedule_once(self.start_widget_dragging, 0.5)

            x, y = self.to_local(*touch.pos)
            target = self.find_target(x, y, self.root)
            self.selected_widget = target
            App.get_running_app().focus_widget(target)
            self.clicked = True
            self.dispatch("on_show_edit", Playground)
            return True

        if self.parent.collide_point(*touch.pos):
            super(Playground, self).on_touch_down(touch)

        return False
コード例 #5
0
				def on_back_pressed( self , *args ) :
					"""

					:return:
					"""

					App.get_running_app().logger.info( 'on_back' )
コード例 #6
0
ファイル: Utility.py プロジェクト: ubuntunux/KivyProject
 def run(self, startPoint = None):
   self.startPoint = startPoint
   self.regist(startPoint)
   # start method
   if hasattr(startPoint, "start"):
     self.startAppList.append(startPoint)
   App.run(self)
コード例 #7
0
ファイル: window_sdl2.py プロジェクト: Bakterija/kivy
    def _event_filter(self, action):
        from kivy.app import App
        if action == 'app_terminating':
            EventLoop.quit = True
            self.close()

        elif action == 'app_lowmemory':
            self.dispatch('on_memorywarning')

        elif action == 'app_willenterbackground':
            from kivy.base import stopTouchApp
            app = App.get_running_app()
            if not app:
                Logger.info('WindowSDL: No running App found, exit.')
                stopTouchApp()
                return 0

            if not app.dispatch('on_pause'):
                Logger.info('WindowSDL: App doesn\'t support pause mode, stop.')
                stopTouchApp()
                return 0

            self._pause_loop = True

        elif action == 'app_didenterforeground':
            # on iOS, the did enter foreground is launched at the start
            # of the application. in our case, we want it only when the app
            # is resumed
            if self._pause_loop:
                self._pause_loop = False
                app = App.get_running_app()
                app.dispatch('on_resume')

        return 0
コード例 #8
0
ファイル: frontscreen.py プロジェクト: cruor99/sadpandareader
 def enter_gallery(self, instance):
     galleryinfo = [instance.gallery_id, instance.gallery_token,
                    instance.pagecount, instance.gallery_name,
                    instance.gallery_tags, instance.gallery_thumb, instance.filesize]
     existgallery = db.query(Gallery).filter_by(
         gallery_id=instance.gallery_id).first()
     if existgallery:
         pass
     else:
         gallery = Gallery(gallery_id=instance.gallery_id,
                           gallery_token=instance.gallery_token,
                           pagecount=instance.pagecount,
                           gallery_name=instance.gallery_name,
                           gallery_thumb=instance.gallery_thumb,
                           filesize=instance.filesize)
         db.add(gallery)
         db.commit()
         for tag in instance.gallery_tags:
             gallerytag = GalleryTags(galleryid=gallery.id, tag=tag)
             db.add(gallerytag)
             db.commit()
     preview_screen = App.get_running_app(
     ).root.ids.sadpanda_screen_manager.get_screen("gallery_preview_screen")
     preview_screen.gallery_id = instance.gallery_id
     App.get_running_app().root.next_screen("gallery_preview_screen")
コード例 #9
0
ファイル: settingsscreen.py プロジェクト: gandie/PlanetAppV2
 def on_leave(self):
     '''write setting to logic and save to file'''
     for key in self.logic.settings:
         if key in self.setting_items:
             self.logic.settings[key] = self.setting_items[key].value
     self.logic.apply_settings()
     App.get_running_app().settings.save()
コード例 #10
0
	def update_file_layout(self):
		auth_token='S2_xUq0_iNAAAAAAAAAACYNG1zf1GAzKpVWVfmLcZLA-FIiSlGxMvmxBkAtspuWQ'
		client = dropbox.client.DropboxClient(auth_token)
		self.clear_widgets()  
		b=BoxLayout(orientation='vertical')
		file_system = FileSystemLocal()
		root_dir= App.get_running_app().user_data_dir+'/';result_dir=root_dir+'results'
		file_list=file_system.listdir(root_dir)   # this returns a list of files in dir
		if os.path.exists(result_dir):file_list.extend(file_system.listdir(App.get_running_app().user_data_dir+'/'+'results'+'/'))
		file_list=[x for x in file_list if x[-4:]=='.csv']
		b.add_widget(Label(text='Select Files to Upload',bold=True,font_size=sp(25),size_hint_y= 0.1))      
		file_system = FileSystemLocal()
		file_list=file_system.listdir(App.get_running_app().user_data_dir+'/')   # this returns a list of files in dir
		file_list=[x for x in file_list if x[-4:]=='.csv']
		s=ScrollView(size_hint_y=0.75)
		g=GridLayout(cols=2,size_hint_y=None)
		for file_1 in file_list:
			c=CheckBox(active=False)
			l=Label(bold= True,font_size=sp(20),text=file_1,size_hint_y= None,height=70)
			self.check_boxes[c]=file_1
			g.add_widget(l);g.add_widget(c)
		g.bind(minimum_height=g.setter('height'))
		s.add_widget(g)
		b.add_widget(s)
		g_options=GridLayout(cols=2,size_hint_y= 0.1,orientation='horizontal')       
		g_options.add_widget(Button(text="Send",on_press=self.upload,font_size=sp(25)))
		g_options.add_widget(Button(text="Back",on_press=self.return_back,font_size=sp(25)))
		b.add_widget(g_options)
		self.add_widget(b)
コード例 #11
0
ファイル: playground.py プロジェクト: dessant/kivy-designer
    def allowed_target_for(self, target, widget):
        '''This function is used to determine if widget could be added to
           target.
        '''
        # stop on complex widget
        t = target if widget else target.parent
        if isinstance(t, FileChooserListView):
            return False
        if isinstance(t, FileChooserIconView):
            return False

        # stop on custom widget but not root widget
        class_rules = App.get_running_app().root.\
            project_loader.class_rules
        root_widget = App.get_running_app().root.\
            project_loader.root_rule.widget

        # if we don't have widget, always return true
        if widget is None:
            return True

        is_widget_layout = isinstance(widget, Layout)
        is_target_layout = isinstance(target, Layout)
        if is_widget_layout and is_target_layout:
            return True

        if is_target_layout or isinstance(target, Carousel):
            return True

        return False
コード例 #12
0
ファイル: playground.py プロジェクト: dessant/kivy-designer
    def do_paste(self):
        '''Paste the selected widget to the current widget
        '''
        parent = self.selected_widget
        if parent and self.widget_to_paste:
            class_rules = App.get_running_app().root.\
                project_loader.class_rules
            root_widget = App.get_running_app().root.\
                project_loader.root_rule.widget
            is_child_custom = False
            for rule in class_rules:
                if rule.name == type(parent).__name__:
                    is_child_custom = True
                    break

            # find appropriate parent to add widget_to_paste
            while parent:
                if isinstance(parent, Layout) and (not is_child_custom
                                                   or root_widget == parent):
                    break

                parent = parent.parent
                is_child_custom = False
                for rule in class_rules:
                    if rule.name == type(parent).__name__:
                        is_child_custom = True
                        break

            if parent is not None:
                self.add_widget_to_parent(self.widget_to_paste,
                                          parent,
                                          kv_str=self._widget_str_to_paste)
                self.widget_to_paste = None
コード例 #13
0
    def on_touch_move(self, touch):
        if touch.grab_current is not self:
            return False
        
        handled = super(DwellOnScatter, self).on_touch_move(touch)
		
        
        if handled:
            if self.ignore_dwell is not True:
                #if self.collide_point(touch.x, touch.y): # check dwell on myself, not the kids (todo: refine?)
                if self.dwell_started_by_touch != touch:
                    self.dwell_started_counter = 0
                    if self.dwell_started_by_touch is not None:
                        root = App.get_running_app().root
                        root.canvas.remove_group(self.dwell_started_by_touch.ud['dwell'])
                    self.dwell_started_by_touch = None
                    Clock.unschedule(self.process_dwell)
                else:
                    # rather than base the calculation on the last touch frame, which means the user might be so slow, that a dwell follows them
                    # base it on the original touch position, with the dwell_jitter_distance essentially mimicing a radius
                    # around which a point can be within for the dwell to not be cancelled out
                    diff = [abs(i-j) for i, j in zip(self.dwell_started_by_touch.opos,self.dwell_started_by_touch.pos)]
                    #if abs(self.dwell_started_by_touch.dx) >= self.dwell_jitter_distance_ignore or abs(self.dwell_started_by_touch.dy) >= self.dwell_jitter_distance_ignore:
                    if diff[0] >= self.dwell_jitter_distance_ignore or diff[1] >= self.dwell_jitter_distance_ignore:
                        self.dwell_started_counter = 0
                        if self.dwell_started_by_touch is not None:
                            root = App.get_running_app().root
                            root.canvas.remove_group(self.dwell_started_by_touch.ud['dwell'])
                        self.dwell_started_by_touch = None
                        Clock.unschedule(self.process_dwell)
                    else:
                        pass # ignore little movements

        return handled
コード例 #14
0
ファイル: MainApp.py プロジェクト: meisterlumpi/WeatherPal
 def run(self):
     con_error_cnt = 0
     while self.keep_running:
         print 'connecting to weather'
         try:
             owm_is_online = self.link.is_API_online()
         except:  # api_call_error.APICallError
             con_error_cnt += 1
             print 'connection to OWM API failed'
             if con_error_cnt < 10:
                 print 'will try again in 2 seconds'
                 time.sleep(2)  # wait 2 seconds before trying it again
                 continue
             else:
                 # quit if connection could not be est. 10 times in a row
                 print 'OWM API seems to be offline, quitting'
                 break
         con_error_cnt = 0  # reset connection error counter if connection was successful
         if owm_is_online:
             obs = self.link.weather_at_place(location_str)
             App.get_running_app().owm_thread_weather = obs.get_weather()
         else:
             App.get_running_app().owm_thread_weather = None
             print('OWM service is offline')
         time.sleep(owm_fetch_sleep_time)  # should be last statement in while loop
コード例 #15
0
ファイル: main.py プロジェクト: pEEcor/presse
    def logfile_end_and_save(self, temp, pres):
        t = time.localtime(App.get_running_app().root.ph.processStart)[0:6]
        t_string = self.get_pretty_print_time(t[3], t[4], t[5], "-")
        date = self.get_pretty_print_time(t[0], t[1], t[2], ".")
        profile_name = App.get_running_app().root.ph.profile.name
        file = open(self.get_log_directory()+"/"+ date + "_" + t_string + "_" + profile_name + ".txt", "w")
        # put logged data into file when process has finished
        for entity in self.logdata:
            file.write(entity)

        if len(temp) > 0:
            time_string = "Time: ["
            temp_string = "Temperature: ["
            pres_string = "Presssure: ["
            for i in range(0, len(temp)-1):
                temp_string = temp_string + str(round(temp[i][1], 2)) + ","
                pres_string = pres_string + str(round(pres[i][1], 2)) + ","
                time_string = time_string + str(round(temp[i][0], 2)) + ","

            temp_string = temp_string + str(temp[-1][1]) + "]"
            pres_string = pres_string + str(pres[-1][1]) + "]"
            time_string = time_string + str(temp[-1][0]) + "]"

            file.write("\n")
            file.write("Logged Temperature and Pressure Data")
            file.write("\n")
            file.write(time_string)
            file.write("\n")
            file.write(temp_string)
            file.write("\n")
            file.write(pres_string)
        file.close()
        # clear logdata
        self.logdata = []
        pass
コード例 #16
0
ファイル: theme.py プロジェクト: grmcom/kivymd
	def __init__(self, **kwargs):
		if hasattr(App.get_running_app(), 'theme_cls'):
			self._theme_cls = App.get_running_app().theme_cls
		else:
			self._theme_cls = ThemeManager()
		super(ThemeBehaviour, self).__init__(**kwargs)
		self._rip_color = self._theme_cls.ripple_color
コード例 #17
0
    def __init__(self, **kwargs):
        super(BTCommunicator, self).__init__(**kwargs)
        self.register_event_type('on__connected')
        self.register_event_type('on_dis_connected')
        self.register_event_type('on_command_sent')
        self.register_event_type('on_response')
        self.register_event_type('on_error')
        self.register_event_type('on_unknown')
        App.get_running_app().bind(on_stop=self.stop_reader_stream)
        curdir = dirname(__file__)
        try:
            with open(join(curdir, 'lang', '{}.json'.format(self.language))) as lang_file:
                self._lang = json.load(lang_file)
        except Exception as e:
            raise BTCommunicatorException("Couldn't load {}/lang/{}.json\nError: {}".format(curdir, self.language, e.message))

        if platform == 'android':
            self.BluetoothAdapter = jnius.autoclass('android.bluetooth.BluetoothAdapter')
            self.BluetoothDevice = jnius.autoclass('android.bluetooth.BluetoothDevice')
            self.BluetoothSocket = jnius.autoclass('android.bluetooth.BluetoothSocket')
            self.InputStreamReader = jnius.autoclass('java.io.InputStreamReader')
            self.BufferedReader = jnius.autoclass('java.io.BufferedReader')
            self.IOException = jnius.autoclass('java.io.IOException')
            self.UUID = jnius.autoclass('java.util.UUID')
        return
コード例 #18
0
ファイル: main.py プロジェクト: kockiya/Flashcards
 def hook_keyboard(self, window, key, *largs):
     if key == 27:
         if FlashcardAppManager.s_manager.current != 'menu':
             FlashcardAppManager.s_manager.current = 'menu'
         else:
             App.get_running_app().stop()
     return True 
コード例 #19
0
ファイル: pakifa.py プロジェクト: j7sx/pakifa
 def run_project(self, project):
     config = ConfigParser()
     config.read('config.ini')
     config.set('Project', 'open_project', project)
     with open('config.ini', 'wb') as configfile:
         config.write(configfile)
     App.get_running_app().stop()
コード例 #20
0
ファイル: main.py プロジェクト: karlitos/Raspberry-Wall
    def on_keyboard_down(self, keyboard, keycode, text, modifiers):

        key = keycode[1]
        print 'keyboard screen manager', key, text
        # general key bindings
        if key == 'q':
            App.get_running_app().stop()
            return True
        # key binding for the wall
        elif self.current == 'Wall screen':
            if ((key == 'up' and self.current_active_post_index > 0) or
                    (key == 'down' and self.current_active_post_index < self.number_of_posts - 1))\
                    and not self.movement_flag:
                next_index = self.current_active_post_index + 1 if key == 'down' else self.current_active_post_index - 1
                self.ids['pw'].scroll_wall(next_index)
                return True
            elif key == 'enter':
                self.ids['pc'].index = self.current_active_post_index
                self.current = 'Carousel screen'
                return True
        # key bindings for the carousel
        elif self.current == 'Carousel screen':
            if key == 'up' and self.current_active_post_index > 0 and not self.movement_flag:
                self.ids['pc'].load_previous()
                self.current_active_post_index -= 1
            elif key == 'down' and self.current_active_post_index < self.number_of_posts - 1 and not self.movement_flag:
                self.ids['pc'].load_next()
                self.current_active_post_index += 1
            elif key == 'backspace':
                self.ids['pw'].move_wall_to_index(self.current_active_post_index)
                self.current = 'Wall screen'
                return True
コード例 #21
0
ファイル: popups.py プロジェクト: miikama/kiltispiikki
 def update_tab_value(self, callback):
     if self.balance_input.text.isnumeric():
         App.get_running_app().man.customer_handler.update_tab_value(self.customer, float(self.balance_input.text))
         self.customer_layout.ids.balance_label.text = str(float(self.balance_input.text))
         self.dismiss()       
     else:
         self.info_label.text = "Not valid number"
コード例 #22
0
ファイル: robotapp.py プロジェクト: swordmaster2k/robotics
    def __init__(self):
        """

        :return:
        """
        App.__init__(self)

        # Connection
        self.connection = "DUMMY"
        self.proxy = Proxy(self.connection)
        self.proxy.start()

        # Model
        self.robot = SimulatedRobot(self.proxy)
        self.robot.cell_size = 0.3
        self.robot.x = 0.3
        self.robot.y = 0.3

        self.map_model = Map(self.robot, 3.0, 0.3)
        self.state = State.default
        self.brush = "start"

        self.planning_algorithm = GridNav(self.map_model)
        self.planner = Planner(self.robot, self.map_model, self.planning_algorithm, self.proxy)

        # View
        self.map_widget = None
        self.panel_widget = None
        self.toolbar_widget = None
        self.horizontal_layout = None
        self.vertical_layout = None
        self.popup = None

        self.plan()
コード例 #23
0
ファイル: ExdApp.py プロジェクト: sne3ks/Exode
    def __init__(self):
        App.__init__(self)
        self.STACK= ExdStack()

        self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
        self._keyboard.bind(on_key_down=self._on_keyboard_down)
        self.keyEvents = {}
コード例 #24
0
    def search_tag(self, instance):

        tag = instance.text
        search = Search(searchterm=tag)
        db.add(search)
        db.commit()
        App.get_running_app().root.next_screen("front_screen")
コード例 #25
0
ファイル: main.py プロジェクト: gandie/PlanetApp
    def on_touch_move(self, touch):
        if touch.grab_current is not self:
            return
        touch.push()
        touch.apply_transform_2d(self.to_local)
        ud = touch.ud

        # typecasting-problems during cross-compiling
        # leads to this ugly construction like in calc_hillbodies
        foo = App.get_running_app().config.get('planetapp','showtrajectorymode')
        trajectorylength = int(App.get_running_app().config.get('planetapp',
                                                                'trajectorylength'))
        if foo == u'0':
            ud['lines'][0].points = (ud['firstpos'][0],ud['firstpos'][1],
                                     touch.x,touch.y)
        else:
            velocity = ((ud['firstpos'][0] - touch.x) / -50, 
                        (ud['firstpos'][1] - touch.y) / - 50)
            planetpos = (ud['firstpos'][0], ud['firstpos'][1])
            sunpos = (self.width/2,self.height/2)
            trajectory = self.calc_trajectory(planetpos, velocity, 
                                              self.planetmass, sunpos, 
                                              self.sunmass, 1, 
                                              trajectorylength)  
            ud['lines'][0].points = trajectory

        touch.pop()
コード例 #26
0
ファイル: customer.py プロジェクト: miikama/kiltispiikki
 def upload_to_drive():
     google_client = DriveClient()
     google_client.upload_file(csv_name)
     App.get_running_app().settings.update_settings(update_time=time_str)
     os.remove(csv_name)            
     InformationPopup('File uploaded')
     Logger.info('CustomerHandler: upload thread finished')
コード例 #27
0
ファイル: main.py プロジェクト: Magnie/simplydogfighting
 def __init__(self):
     App.__init__(self)
     self.connected = True
     self.Connect((HOST, PORT))
     
     self.count = 0
     self.time = 0
コード例 #28
0
ファイル: mainscreen.py プロジェクト: ohaz/Colours
 def leave_game(self):
     """
     Ends the game by stopping the app
     :return:
     """
     # Exit the application, clean up
     App.get_running_app().stop()
コード例 #29
0
ファイル: main.py プロジェクト: inclement/noGo
 def make_board_match_view_mode(self, name):
     board = self.get_screen(name)
     if self.view_mode[:6] == 'tablet':
         if not isinstance(board.children[0], TabletBoardView):
             print 'REFRESHING -> tbv'
             board = self.get_screen(name)
             self.close_board(name)
             board = board.children[0]
             board.board.save_sgf()
             filen = board.board.collectionsgf.filen
             reconstruction_path = board.board.get_reconstruction()
             new_pbv = self.new_board(from_file=filen, mode='Navigate')
             new_pbv.board.reconstruct_from(reconstruction_path)
             new_pbv.board.comment_pre_text = 'This [b]tablet mode[/b] is currently experimental. It should work fine, but is still being tested and will be subject to change (more efficient layout etc.) and speed optimisation before being finalised.\n-----\n'
             App.get_running_app().manager.refresh_open_games()
     else:
         if not isinstance(board.children[0], PhoneBoardView):
             print 'REFRESHING -> pbv'
             board = self.get_screen(name)
             self.close_board(name)
             board = board.children[0]
             board.board.save_sgf()
             filen = board.board.collectionsgf.filen
             reconstruction_path = board.board.get_reconstruction()
             new_pbv = self.new_board(from_file=filen, mode='Navigate')
             new_pbv.board.reconstruct_from(reconstruction_path)
             App.get_running_app().manager.refresh_open_games()
コード例 #30
0
ファイル: setup.py プロジェクト: jeffmacinnes/pyneal
    def submitGUI(self):
        """ Submit the GUI

        Get all settings, confirm they are valid, save new settings file

        """
        ## Error Check All GUI SETTINGS
        errorCheckPassed = self.check_GUI_settings()

        # write GUI settings to file
        if errorCheckPassed:
            # Convery the GUI_settings from kivy dictproperty to a regular ol'
            # python dict (and do some reformatting along the way)
            allSettings = {}
            for k in self.GUI_settings.keys():
                # convert text inputs to integers
                if k in ['pynealScannerPort', 'resultsServerPort', 'numTimepts']:
                        allSettings[k] = int(self.GUI_settings[k])
                else:
                    allSettings[k] = self.GUI_settings[k]

            # write the settings as the new config yaml file
            with open(setupConfigFile, 'w') as outputFile:
                yaml.dump(allSettings, outputFile, default_flow_style=False)

            # Close the GUI
            global submitButtonPressed
            submitButtonPressed = True
            App.get_running_app().stop()
            EventLoop.exit()
コード例 #31
0
 def setUVBackground(self):
     self.uvBackground = App.get_running_app().Obs['UVIndex'][3]
コード例 #32
0
ファイル: main.py プロジェクト: jntp/ForecastSend2.0
 def no(self):
     App.get_running_app().stop()  # exit the application
コード例 #33
0
ファイル: main3.py プロジェクト: gauderkd/GrandStair
 def on_enter(self):
     play_stim_set(
         [App.get_running_app().stimulus,
          App.get_running_app().probe])
コード例 #34
0
ファイル: main3.py プロジェクト: gauderkd/GrandStair
 def on_enter(self):  # This code will run when exit screen is entered!
     print('in exit screen')
     print(
         App.get_running_app().response
     )  # Note this reference to the app class is an easy way to point to these properties!
コード例 #35
0
ファイル: main.py プロジェクト: tonymorony/OraclesCC_Chat-GUI
 def messages_checker(self, dt):
     while True:
         if App.get_running_app().is_connected == False:
             break
         else:
             # getting oraclesinfo for active room
             oracles_info = rpclib.oracles_info(
                 App.get_running_app().rpc_connection,
                 App.get_running_app().active_room_id)
             if App.get_running_app().active_room_id == '':
                 print("Seems messages grabbing works")
                 break
             else:
                 # flushing it to not print previous messages
                 baton_returned = {}
                 # getting batons to print on each iteration
                 data_to_print = {}
                 # getting dictionary with current batontxid for each publisher
                 for entry in oracles_info["registered"]:
                     baton_returned[entry["publisher"]] = entry["batontxid"]
             # updating batons for all publishers in app array
                 for publisher in baton_returned:
                     if publisher in App.get_running_app().current_baton:
                         # if publisher already here updating baton and adding it to print queue
                         if baton_returned[publisher] != App.get_running_app(
                         ).current_baton[publisher]:
                             App.get_running_app().current_baton[
                                 publisher] = baton_returned[publisher]
                             try:
                                 data_to_print[
                                     publisher] = rpclib.oracles_samples(
                                         App.get_running_app(
                                         ).rpc_connection,
                                         App.get_running_app(
                                         ).active_room_id,
                                         baton_returned[publisher],
                                         "1")['samples'][0][0]
                             except IndexError:
                                 break
             # if baton is the same as before there is nothing to update
                         else:
                             break
             # if publisher not here adding it with latest baton and adding baton to print queue
                     else:
                         App.get_running_app().current_baton[
                             publisher] = baton_returned[publisher]
                         try:
                             data_to_print[
                                 publisher] = rpclib.oracles_samples(
                                     App.get_running_app().rpc_connection,
                                     App.get_running_app().active_room_id,
                                     baton_returned[publisher],
                                     "1")['samples'][0][0]
                         except IndexError:
                             break
             # finally printing messages
             try:
                 for publisher in data_to_print:
                     message_list = ast.literal_eval(
                         data_to_print[publisher].replace('\r',
                                                          '\\r').replace(
                                                              '\n', '\\n'))
                     kvsearch_result = rpclib.kvsearch(
                         App.get_running_app().rpc_connection, publisher)
                     if 'value' in kvsearch_result:
                         addr = str(
                             P2PKHBitcoinAddress.from_pubkey(x(publisher)))
                         signature = kvsearch_result['value'][:88]
                         value = kvsearch_result['value'][88:]
                         verifymessage_result = rpclib.verifymessage(
                             App.get_running_app().rpc_connection, addr,
                             signature, value)
                         if verifymessage_result:
                             message_to_print = datetime.utcfromtimestamp(
                                 message_list[0]).strftime(
                                     '%D %H:%M') + '[' + kvsearch_result[
                                         'value'][88:] + '-' + publisher[
                                             0:10] + ']:' + message_list[1]
                         else:
                             message_to_print = 'IMPROPER SIGNATURE' + datetime.utcfromtimestamp(
                                 message_list[0]).strftime(
                                     '%D %H:%M') + '[' + kvsearch_result[
                                         'value'][88:] + '-' + publisher[
                                             0:10] + ']:' + message_list[1]
                     else:
                         message_to_print = datetime.utcfromtimestamp(
                             message_list[0]).strftime(
                                 '%D %H:%M') + '[' + publisher[
                                     0:10] + ']:' + message_list[1]
                     App.get_running_app().messages.append(message_to_print)
                     App.get_running_app(
                     ).root.ids.messagesview.adapter.data = App.get_running_app(
                     ).messages
                 break
             except bitcoinrpc.authproxy.JSONRPCException as e:
                 print(App.get_running_app().active_room_id)
                 print(e)
                 break
コード例 #36
0
ファイル: main.py プロジェクト: tonymorony/OraclesCC_Chat-GUI
 def send_message(instance, inputid):
     new_message = chatlib.message_sending(
         App.get_running_app().rpc_connection,
         App.get_running_app().active_room_id, str(inputid.text))
     print(new_message)
     inputid.text = ''
コード例 #37
0
ファイル: main.py プロジェクト: tonymorony/OraclesCC_Chat-GUI
 def subscribe_room(self, utxos_amount):
     chatlib.room_subscription(App.get_running_app().rpc_connection,
                               str(App.get_running_app().active_room_id),
                               utxos_amount)
コード例 #38
0
ファイル: main.py プロジェクト: tonymorony/OraclesCC_Chat-GUI
 def create_nickname(self, nickname, password):
     new_nickname = chatlib.set_nickname(
         App.get_running_app().rpc_connection, nickname, password)
     print(new_nickname)
コード例 #39
0
ファイル: nodes.py プロジェクト: devkral/chatscn
 def load_selected(self, selected):
     if not selected:
         return
     root = App.get_running_app().root
     root.set_namehash(selected)
     root.ids["convershash"].text = selected
コード例 #40
0
ファイル: nodes.py プロジェクト: devkral/chatscn
 def load_direct(self):
     root = App.get_running_app().root
     root.set_namehash(self.entry[1])
     root.ids["convershash"].text = self.entry[1]
コード例 #41
0
ファイル: nodes.py プロジェクト: devkral/chatscn
 def delete_friend_afterask(self):
     root = App.get_running_app().root
     ret = root.requester.requester.do_request("/client/delentity",
                                               {"name": self.text})
     if logcheck(ret):
         root.load_friends()
コード例 #42
0
ファイル: nodes.py プロジェクト: devkral/chatscn
 def add_friend_after(self, name):
     root = App.get_running_app().root
     self.entry[3] = name
     d = {"name": name, "hash": self.entry[1], "type": "client"}
     root.requester.requester.do_request("/client/addhash", d, {})
     self.update_friend()
コード例 #43
0
 def on_parent(self, instance, value):
     if value:
         app = App.get_running_app()
         self._back = _back = partial(self.ids.back.dispatch, 'on_release')
コード例 #44
0
 def show_error(self, msg):
     app = App.get_running_app()
     Clock.schedule_once(lambda dt: app.show_error(msg))
コード例 #45
0
 def on_dismiss(self):
     app = App.get_running_app()
     if app.wallet is None and not self._on_release:
         app.stop()
コード例 #46
0
 def on_parent(self, instance, value):
     if value:
         app = App.get_running_app()
         self._back = _back = partial(app.dispatch, 'on_back')
コード例 #47
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self._shadow = App.get_running_app().theme_cls.round_shadow
コード例 #48
0
ファイル: main.py プロジェクト: GilmarJr027/Estudo-Kivy
#coding: utf-8
from kivy.app import App
from kivy.uix.label import Label


def build():

    lbl_text = Label()
    lbl_text.text = 'Curso de Python e Kivy'
    lbl_text.italic = True
    lbl_text.font_size = 50
    return lbl_text


iniciar = App()
iniciar.build = build
iniciar.run()
コード例 #49
0
 def setBarometerArrow(self):
     self.barometerArrow = App.get_running_app().Obs['Pres'][2]
コード例 #50
0
    def execute_run(self):
        valuation_home = self.manager.parent.parent.manager.get_screen(
            'valuation_home')
        ss = self.manager.get_screen('selection_summary')

        # Parse selection summary for arguments to pass to ValOp handler.
        wiz_selections = ss.wiz_selections
        iso = wiz_selections['iso']
        node = wiz_selections['node']
        nodeid = wiz_selections['nodeid']

        data_manager = App.get_running_app().data_manager
        rev_streams = data_manager.get_valuation_revstreams(
            iso, nodeid)[wiz_selections['rev_streams']]['market type']

        hist_data = wiz_selections['selected_data']
        device = wiz_selections['device']

        handler_requests = {}
        handler_requests['iso'] = iso
        handler_requests[
            'market type'] = rev_streams  # need this as string, not list
        handler_requests['months'] = [(entry['month'], entry['year'])
                                      for entry in hist_data]
        handler_requests['node id'] = nodeid
        handler_requests['param set'] = [{
            param.desc['attr name']: param.param_slider.value
            for param in device
        }]

        # Send requests to ValOp handler.
        valop_handler = valuation_home.handler
        valop_handler.solver_name = App.get_running_app().config.get(
            'optimization', 'solver')
        self.solved_ops, handler_status = valop_handler.process_requests(
            handler_requests)

        # If no optimizations were solved successfully, bail out.
        if not self.solved_ops:
            popup = WizardCompletePopup()

            popup.title = "Hmm..."
            popup.popup_text.text = "Unfortunately, none of the models were able to be solved. This is likely due to no data being available for the node selected. Try selecting another pricing node next time. (You selected {0}.)".format(
                node)
            popup.results_button.text = "Take me back"
            popup.bind(on_dismiss=lambda x: self.manager.parent.parent.manager.
                       nav_bar.go_up_screen())  # Go back to Valuation Home
            popup.open()
            return

        # Save selection summary details to pass to report generator.
        deviceSelectionButtons = self.manager.get_screen(
            'device_select').device_select.children
        selectedDeviceName = [
            x.text for x in deviceSelectionButtons if x.state == "down"
        ][0]

        self.report_attributes = {
            'market area':
            iso,
            'pricing node':
            node,
            'selected device':
            selectedDeviceName,
            'dates analyzed':
            ' to '.join([
                ' '.join([
                    calendar.month_name[int(hist_data[0]['month'])],
                    hist_data[0]['year']
                ]),
                ' '.join([
                    calendar.month_name[int(hist_data[-1]['month'])],
                    hist_data[-1]['year']
                ]),
            ]),
            'revenue streams':
            wiz_selections['rev_streams'],
            'market type':
            rev_streams,
        }

        for param in device:
            self.report_attributes[
                param.desc['attr name']] = param.param_slider.value

        popup = WizardCompletePopup()

        if not handler_status:
            popup.title = "Success!*"
            popup.popup_text.text = "All calculations finished. Press 'OK' to proceed to the results.\n\n*At least one model (month) had issues being built and/or solved. Any such model will be omitted from the results."

        popup.bind(on_dismiss=self._next_screen)
        popup.open()
コード例 #51
0
 def setLightningBoltIcon(self):
     if App.get_running_app().Obs['StrikeDeltaT'][4] != '-':
         if App.get_running_app().Obs['StrikeDeltaT'][4] < 360:
             self.lightningBoltIcon = 'lightningBoltStrike'
         else:
             self.lightningBoltIcon = 'lightningBolt'
コード例 #52
0
 def __init__(self, **kwargs):
     super(BarometerPanel, self).__init__(**kwargs)
     App.get_running_app().BarometerPanel = self
     self.setBarometerArrow()
コード例 #53
0
 def __init__(self, **kwargs):
     super(RainfallPanel, self).__init__(**kwargs)
     App.get_running_app().RainfallPanel = self
     Clock.schedule_once(self.Clock)
     self.animateRainRate()
コード例 #54
0
 def __init__(self, **kwargs):
     super(LightningPanel, self).__init__(**kwargs)
     App.get_running_app().LightningPanel = self
     self.setLightningBoltIcon()
コード例 #55
0
ファイル: main3.py プロジェクト: gauderkd/GrandStair
 def on_pre_enter(self):
     self.lbl.value = 1
     App.get_running_app().response_made = False
コード例 #56
0
 def __init__(self, **kwargs):
     super(MoonPhasePanel, self).__init__(**kwargs)
     App.get_running_app().MoonPhasePanel = self
コード例 #57
0
 def __init__(self, **kwargs):
     super(WindSpeedPanel, self).__init__(**kwargs)
     App.get_running_app().WindSpeedPanel = self
     self.setWindIcons()
コード例 #58
0
 def setWindIcons(self):
     self.windDirIcon = App.get_running_app().Obs['WindDir'][2]
     self.windSpdIcon = App.get_running_app().Obs['WindSpd'][3]
コード例 #59
0
ファイル: main3.py プロジェクト: gauderkd/GrandStair
 def slide_response(self, *args):
     App.get_running_app().response = round(args[1], 1)
     App.get_running_app().response_made = True
コード例 #60
0
 def __init__(self, **kwargs):
     super(SunriseSunsetPanel, self).__init__(**kwargs)
     App.get_running_app().SunriseSunsetPanel = self
     self.setUVBackground()