Python kivy 模块,clock() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用kivy.clock()

项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def update(self, *args):

        global clocktheme

        temp_f_string = str(temp_f)

        if int(float(animation_start_time))+5 <= int(float(time_second_mod)): #animation is delayed for better asthetics       
            if TEMPON == 1:
                if clocktheme == 2: # if analog clock is black, temp display is updated dynamically
                    #comment out next line for dev work - no temp sensor connected
                    if TempProbePresent == 1:
                            read_temp()     # If clock is shown, it goes really slow when updated dynamically
                            self.text = temp_f_string + u'\N{DEGREE SIGN}'
                    if TempProbePresent == 0:
                            self.text = "--" + u'\N{DEGREE SIGN}'
                if clocktheme != 2:
                    self.text = " "
            if TEMPON == 0: 
                self.text = " "
        self.font_size = 30
        self.pos = (354,140)
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def build(self):
        global root
        root = ROOT() #set root widget (does nothing)


        clockwidget = CLOCK() #sets clock widget
        messagewidget = MESSAGE() #sets the message widget
        analogclock = MyClockWidget() #sets the analog clock widget
        cabintempwidget = CabinTempWidget() #sets the temp widget in upper right corner on main screen
        obdgaugewidget = OBDGaugeWidget() #sets the gauge widget in the middle of the screen


        Clock.schedule_interval(clockwidget.update, .1) #updates the main menu clock

        Clock.schedule_interval(analogclock.ticks.update_clock, .1) #updates the analog clock

        Clock.schedule_interval(messagewidget.update, .104556) #updates the message display

        #Clock.schedule_once(cabintempwidget.update) #call once to get initial temp
        Clock.schedule_interval(cabintempwidget.update, .1) #updates the temp every 10th second

        Clock.schedule_interval(obdgaugewidget.update, .1) #updates the temp every 10th second

        #add the widgets

        root.add_widget(KVFILE) #adds the main GUI

        root.add_widget(clockwidget) #main digital clock
        root.add_widget(analogclock) #analog clock
        root.add_widget(messagewidget) #adds message widget

        root.add_widget(cabintempwidget) #adds temp widget
        root.add_widget(obdgaugewidget) #adds obd gauge widget

        return root
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def kill_clock(obj): #use on_release: app.kill_clock() to call
        global clock
        clock = 0
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def add_clock(obj): #use on_release: app.add_clock() to call
        global clock
        clock = 1
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def add_wormsizeclock(obj): #use on_release: app.add_wormsizeclock() to call
        global clock
        clock = 3
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def add_menuclock(obj): #use on_release: app.add_menuclock() to call
        global clock
        clock = 4
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def changeclocktheme(obj): #themes: Green(1), Off(2) - flips thru screens when tapping home analog clock
        global clocktheme
        global animation_start_time
        #animation_start_time = int(float(time_second_mod)) #sets a reference time for animations
        if clocktheme < 3:
            clocktheme += 1
        if clocktheme == 2:
            animation_start_time = int(float(time_second_mod)) #sets a reference time for animations
        if clocktheme == 3:
            clocktheme = 1
项目:CoPilot-InfotainmentSystem    作者:Joelzeller    | 项目源码 | 文件源码
def update(self, *args):
        time_hour = time.strftime("%I") #time_hour

        if time_hour[0] == "0": #one digit format
            time_hour = " "+time_hour[1]

        time_minute = time.strftime("%M") #time_minute

        global time_second_mod
        time_second_mod = int(float(time_second_mod))+1
        if time_second_mod > 10000000: #doesnt allow this var to get too big
            time_second_mod = 0

        time_now = time_hour+":"+time_minute #create sting format (hour:minute)

        if clock == 1: #default - on main screens - top center
            self.font_size = 40 #50 for center
            self.pos = (345, 216) #0, 200 for center
            self.text = time_now

        if clock == 0: #shows nothing
            self.font_size = 60
            self.pos = (0,190)
            self.text = " "

        if clock == 2: #top left - larger - for info clock
            self.font_size = 140
            self.text = time_now
            self.pos = (-200,150)

        if clock == 3: #center - for worm clock
            self.font_size = 60
            self.pos = (0,36)
            self.text = time_now

        if clock == 4: #top right - for menu screens
            self.font_size = 40 #40
            self.pos = (345, 216) #212
            self.text = time_now


        #VARIABLE PRINTER
            #to use - comment out the normal clock == 1 if, and choose a type of var and uncomment

        #if clock == 1:
            #self.font_size = 30
            #self.pos = (0,190)
            #self.text = "%d" %time.hour #+ "%d" %WINDOWSDOWNON #for numbers
            #self.text = str(SettingsScreen.buttons.analogclockswitch.active) #for strings