python类width()的实例源码

data_screen.py 文件源码 项目:glucometer 作者: johnyburd 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def refresh_widths(self):
        i = self.ids
        i.bg._label.refresh()      # have to refresh to update texture size
        i.carbs._label.refresh()
        i.bolus._label.refresh()
        i.notes._label.refresh()
        i.layout.width = sum(x.width for x in self.ids.layout.children)
        totalwidth = i.layout.width + i.time.width
        print totalwidth
        if totalwidth < (Window.width + i.deletebtn.width + i.editbtn.width):
            i.spacer.width = Window.width - totalwidth + i.deletebtn.width + i.editbtn.width
            self.refresh_widths()
Classifier.py 文件源码 项目:Sandra-Programming 作者: pythongiant 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self,stuff):
        close=Label(text=stuff)
        popup=Popup(title="Meetings",size_hint=(None, None), size=(500, 400))

        root=ScrollView(size_hint=(1, None), size=(Window.width, Window.height))
        popup.add_widget(close)
        root.add_widget(popup)
        popup.open()
snackbar.py 文件源码 项目:Blogs-Posts-Tutorials 作者: kiok46 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def begin(self):
        if self.button_text == '':
            self.remove_widget(self.ids['_button'])
        else:
            self.ids['_spacer'].width = dp(16) if \
                DEVICE_TYPE == "mobile" else dp(40)
            self.padding_right = dp(16)
        Window.add_widget(self)
        anim = Animation(y=0, duration=.3, t='out_quad')
        anim.start(self)
        Clock.schedule_once(lambda dt: self.die(), self.duration)
slidingpanel.py 文件源码 项目:Blogs-Posts-Tutorials 作者: kiok46 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def toggle(self):
        Animation.stop_all(self, 'x')
        Animation.stop_all(self.shadow, 'color')
        if self._open:
            if self.side == 'left':
                target_x = -1 * self.width
            else:
                target_x = Window.width

            sh_anim = Animation(duration=self.anim_length_open,
                                t=self.animation_t_open,
                                color=[0, 0, 0, 0])
            sh_anim.start(self.shadow)
            self._get_main_animation(duration=self.anim_length_close,
                                     t=self.animation_t_close,
                                     x=target_x,
                                     is_closing=True).start(self)
            self._open = False
        else:
            if self.side == 'left':
                target_x = 0
            else:
                target_x = Window.width - self.width
            Animation(duration=self.anim_length_open, t=self.animation_t_open,
                      color=[0, 0, 0, 0.5]).start(self.shadow)
            self._get_main_animation(duration=self.anim_length_open,
                                     t=self.animation_t_open,
                                     x=target_x,
                                     is_closing=False).start(self)
            self._open = True
snackbar.py 文件源码 项目:mobileinsight-mobile 作者: mobile-insight 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def begin(self):
        if self.button_text == '':
            self.remove_widget(self.ids['_button'])
        else:
            self.ids['_spacer'].width = dp(16) if DEVICE_TYPE == "mobile" else dp(40)
            self.padding_right = dp(16)
        Window.add_widget(self)
        anim = Animation(y=0, duration=.3, t='out_quad')
        anim.start(self)
        Clock.schedule_once(lambda dt: self.die(), self.duration)
snackbar.py 文件源码 项目:kivy_gosh 作者: mcroni 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def begin(self):
        if self.button_text == '':
            self.remove_widget(self.ids['_button'])
        else:
            self.ids['_spacer'].width = dp(16) if \
                DEVICE_TYPE == "mobile" else dp(40)
            self.padding_right = dp(16)
        Window.add_widget(self)
        anim = Animation(y=0, duration=.3, t='out_quad')
        anim.start(self)
        Clock.schedule_once(lambda dt: self.die(), self.duration)
slidingpanel.py 文件源码 项目:kivy_gosh 作者: mcroni 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def toggle(self):
        Animation.stop_all(self, 'x')
        Animation.stop_all(self.shadow, 'color')
        if self._open:
            if self.side == 'left':
                target_x = -1 * self.width
            else:
                target_x = Window.width

            sh_anim = Animation(duration=self.anim_length_open,
                                t=self.animation_t_open,
                                color=[0, 0, 0, 0])
            sh_anim.start(self.shadow)
            self._get_main_animation(duration=self.anim_length_close,
                                     t=self.animation_t_close,
                                     x=target_x,
                                     is_closing=True).start(self)
            self._open = False
        else:
            if self.side == 'left':
                target_x = 0
            else:
                target_x = Window.width - self.width
            Animation(duration=self.anim_length_open, t=self.animation_t_open,
                      color=[0, 0, 0, 0.5]).start(self.shadow)
            self._get_main_animation(duration=self.anim_length_open,
                                     t=self.animation_t_open,
                                     x=target_x,
                                     is_closing=False).start(self)
            self._open = True
snackbar.py 文件源码 项目:KivyMD 作者: cruor99 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def begin(self):
        if self.button_text == '':
            self.remove_widget(self.ids['_button'])
        else:
            self.ids['_spacer'].width = dp(16) if \
                DEVICE_TYPE == "mobile" else dp(40)
            self.padding_right = dp(16)
        Window.add_widget(self)
        anim = Animation(y=0, duration=.3, t='out_quad')
        anim.start(self)
        Clock.schedule_once(lambda dt: self.die(), self.duration)
slidingpanel.py 文件源码 项目:KivyMD 作者: cruor99 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def toggle(self):
        Animation.stop_all(self, 'x')
        Animation.stop_all(self.shadow, 'color')
        if self._open:
            if self.side == 'left':
                target_x = -1 * self.width
            else:
                target_x = Window.width

            sh_anim = Animation(duration=self.anim_length_open,
                                t=self.animation_t_open,
                                color=[0, 0, 0, 0])
            sh_anim.start(self.shadow)
            self._get_main_animation(duration=self.anim_length_close,
                                     t=self.animation_t_close,
                                     x=target_x).start(self)
            self._open = False
        else:
            if self.side == 'left':
                target_x = 0
            else:
                target_x = Window.width - self.width
            Animation(duration=self.anim_length_open, t=self.animation_t_open,
                      color=[0, 0, 0, 0.5]).start(self.shadow)
            self._get_main_animation(duration=self.anim_length_open,
                                     t=self.animation_t_open,
                                     x=target_x).start(self)
            self._open = True
visual_debugger_app.py 文件源码 项目:SerpentAI 作者: SerpentAI 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self):
        super().__init__()

        self.images = dict()

        self.root = FloatLayout(size=(Window.width, Window.height))
        self.grid = GridLayout(cols=8)

        self.add_widget(self.root)
        self.root.add_widget(self.grid)

        for i, bucket in enumerate(config["visual_debugger"]["available_buckets"]):
            layout = BoxLayout(orientation="vertical")

            image = VisualDebuggerImage(
                allow_stretch=True
            )

            image.bind(texture=image.update_texture_filters)

            self.images[bucket] = image

            layout.add_widget(image)

            label = Label(
                text=bucket,
                color=(1, 1, 1, 1),
                size_hint=(1, 0.1)
            )

            layout.add_widget(label)

            self.grid.add_widget(layout)

        Window.bind(on_resize=self.on_window_resize)
        Window.clearcolor = (0.136, 0.191, 0.25, 1)
visual_debugger_app.py 文件源码 项目:SerpentAI 作者: SerpentAI 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def on_window_resize(self, window, width, height):
        self.root.size = (width, height)
app.py 文件源码 项目:mmplayer 作者: Bakterija 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def on_start(self):
        self.store_name = 'MMplayerApp'
        self.store_properties = [
            ('last_size', [Window.width, Window.height]),
            ('last_pos', [Window.left, Window.top])
        ]
        self.update_store_properties()

        self.root.init_widgets()
        self.last_frame_time = time() - TIME0
        Logger.info('App: on_start: %s' % (round(self.last_frame_time, 2)))
        Clock.schedule_once(lambda dt: self.on_some_frame(1, 7), 0)
        Clock.schedule_once(self._load_window_pos_size, 0)
GravBox.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(MyButton, self).__init__(**kwargs)
        self.font_size = Window.width*0.015 #setting font size
GravBox.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(WelcomeScreen, self).__init__(**kwargs)

        self.layout = FloatLayout() #Float Layout for positioning buttons and image anywhere on the screen
        self.layout.width = Window.width #the float layout is the size of the window
        self.layout.height = Window.height
        self.layout.x = Window.width/2 - self.layout.width/2 #sets the x position of the layout to 0
        self.layout.y = Window.height/2 - self.layout.height/2 #sets the y position of the layout to 0
        self.add_widget(self.layout) #adds the layout to the screen

        self.img = Image(source = self.welcomeImage)
        self.img.size = (Window.width*1.0, Window.height*1.2)
        self.img.pos = (-Window.width*0.0, -Window.height*0.0)
        self.img.opacity = 1.0 #alpha value between 0.0 - 1.0
        self.add_widget(self.img) #adds the image to the screen

        tmpBtn1 = MyButton(text = self.buttonList[0]) #start button
        tmpBtn1.size_hint = (.21, .09)
        tmpBtn1.pos_hint ={'x': .395, 'y': .24}
        tmpBtn1.background_color = [.4, .4, .4, .4] #backgroundcolor of the button (this is grayish)
        tmpBtn1.bind(on_release = self.changer) #when the button is released the changer function is called
        self.layout.add_widget(tmpBtn1) #adds the button called tmpBtn1 to the floatlayout

        tmpBtn2 = MyButton(text = self.buttonList[1]) #about button
        tmpBtn2.size_hint = (.08, .095)
        tmpBtn2.pos_hint ={'x': .618, 'y': 0}
        tmpBtn2.background_color = [.4, .4, .4, .4]
        tmpBtn2.bind(on_release = self.about) #when the button is released the about function is called
        self.layout.add_widget(tmpBtn2) #adds the button called tmpBtn2 to the floatlayout

        tmpBtn3 = MyButton(text = self.buttonList[2]) #uiowa button
        tmpBtn3.size_hint = (.08, .095)
        tmpBtn3.pos_hint = {'x':.7, 'y': 0}
        tmpBtn3.background_color = [.4, .4, .4, .4]
        tmpBtn3.bind(on_release = self.uiowa) #when the button is released the uiowa function is called
        self.layout.add_widget(tmpBtn3) #adds the button called tmpBtn3 to the floatlayout
GravBox.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(AboutScreen, self).__init__(**kwargs)

        self.layout = FloatLayout()
        self.layout.width = Window.width
        self.layout.height = Window.height
        self.layout.x = Window.width/2 - self.layout.width/2
        self.layout.y = Window.height/2 - self.layout.height/2
        self.add_widget(self.layout)

        self.img = Image(source = self.aboutImage)
        self.img.size = (Window.width*1.0, Window.height*1.0)
        self.img.pos = (-Window.width*0.0, -Window.height*0.0)
        self.img.opacity = 0.4
        self.add_widget(self.img)

        self.aboutText = Label(text= 'GravBox is the interface application for the Augmented Reality (AR) Sandbox for gravitational dynamics simulations designed and built\n by Dr. Hai Fu\'s Introduction to Astrophysics class during the 2016-2017 academic year and beyond.\n GravBox itself was designed by Zachary Luppen, Erin Maier, and Mason Reed.\n\nAR Sandbox is the result of an NSF-funded project on informal science education for freshwater lake and watershed science developed by the\n UC Davis\' W.M. Keck Center for Active Visualization in the Earth Sciences (KeckCAVES),\n together with the UC Davis Tahoe Environmental Research Center, Lawrence Hall of Science, and ECHO Lake Aquarium and Science Center.')
        self.aboutText.pos = (.5, .5)
        #self.aboutText.size = self.size
        self.add_widget(self.aboutText)

        tmpBtn1 = MyButton(text = 'BACK') #start button
        tmpBtn1.size_hint = (.1, .1)
        tmpBtn1.pos_hint ={'x': 0, 'y': .90}
        tmpBtn1.background_color = [.4, .4, .4, 1]
        tmpBtn1.bind(on_release = self.backButton) #when the button is released the callback function is called
        self.layout.add_widget(tmpBtn1)
GravBox.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(UiowaScreen, self).__init__(**kwargs)

        self.layout = FloatLayout()
        self.layout.width = Window.width
        self.layout.height = Window.height
        self.layout.x = Window.width/2 - self.layout.width/2
        self.layout.y = Window.height/2 - self.layout.height/2
        self.add_widget(self.layout)

        self.img = Image(source = self.uiowaImage)
        self.img.size = (Window.width*1.0, Window.height*1.0)
        self.img.pos = (-Window.width*0.0, -Window.height*0.0)
        self.img.opacity = 0.4
        self.add_widget(self.img)

        self.aboutText = Label(text= 'UIOWA INFO HERE')
        self.aboutText.pos = (.25, .25)
        self.add_widget(self.aboutText)

        tmpBtn1 = MyButton(text = 'BACK') #start button
        tmpBtn1.size_hint = (.1, .1)
        tmpBtn1.pos_hint ={'x': 0, 'y': .9}
        tmpBtn1.background_color = [.4, .4, .4, 1]
        tmpBtn1.bind(on_release = self.backButton) #when the button is released the backButton function is called
        self.layout.add_widget(tmpBtn1)
gravbox-master-erin.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(MyButton, self).__init__(**kwargs)
        self.font_size = Window.width*0.015 #setting font size
gravbox-master-erin.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(AboutScreen, self).__init__(**kwargs)

        layout = FloatLayout()
        layout.width = Window.width
        layout.height = Window.height
        layout.x = Window.width/2 - layout.width/2
        layout.y = Window.height/2 - layout.height/2
        self.add_widget(layout)

        img = Image(source = self.aboutImage)
        img.size = (Window.width*1.0, Window.height*1.0)
        img.pos = (-Window.width*0.0, -Window.height*0.0)
        img.opacity = 0.4
        self.add_widget(img)

        aboutText = Label(text= 'GravBox is the interface application for the Augmented Reality (AR) Sandbox for gravitational dynamics simulations designed and built\nby Dr. Hai Fu\'s Introduction to Astrophysics class during the 2016-2017 academic year and beyond.\nGravBox itself was designed by Zachary Luppen, Erin Maier, and Mason Reed.\n\nAR Sandbox is the result of an NSF-funded project on informal science education for freshwater lake and watershed science developed by the\nUC Davis\' W.M. Keck Center for Active Visualization in the Earth Sciences (KeckCAVES),\ntogether with the UC Davis Tahoe Environmental Research Center, Lawrence Hall of Science, and ECHO Lake Aquarium and Science Center.', halign='center', valign='center')
        aboutText.pos = (.25, .25)
        self.add_widget(aboutText)

        backBtn = MyButton(text = 'BACK') # back button
        backBtn.size_hint = (.1, .1)
        backBtn.pos_hint ={'x': 0, 'y': .90}
        backBtn.background_color = [.4, .4, .4, 1]
        backBtn.bind(on_release = self.backButton) #when the button is released the callback function is called
        self.add_widget(backBtn)
gravbox-master-erin.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(UiowaScreen, self).__init__(**kwargs)

        layout = FloatLayout()
        layout.width = Window.width
        layout.height = Window.height
        layout.x = Window.width/2 - layout.width/2
        layout.y = Window.height/2 - layout.height/2
        self.add_widget(layout)

        img = Image(source = self.uiowaImage)
        img.size = (Window.width*1.0, Window.height*1.0)
        img.pos = (-Window.width*0.0, -Window.height*0.0)
        img.opacity = 0.4
        self.add_widget(img)

        aboutText = Label(text='UIOWA INFO HERE')
        aboutText.pos = (.25, .25)
        self.add_widget(aboutText)

        backBtn = MyButton(text = 'BACK') #start button
        backBtn.size_hint = (.1, .1)
        backBtn.pos_hint ={'x': 0, 'y': .9}
        backBtn.background_color = [.4, .4, .4, 1]
        backBtn.bind(on_release = self.backButton) #when the button is released the backButton function is called
        layout.add_widget(backBtn)
main.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(MyButton, self).__init__(**kwargs)
        self.font_size = Window.width*0.015 #setting font size
main.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(WelcomeScreen, self).__init__(**kwargs)

        layout = FloatLayout() #Float Layout for positioning buttons and image anywhere on the screen
        layout.width = Window.width #the float layout is the size of the window
        layout.height = Window.height
        layout.x = Window.width/2 - layout.width/2 #sets the x position of the layout to 0
        layout.y = Window.height/2 - layout.height/2 #sets the y position of the layout to 0
        self.add_widget(layout) #adds the layout to the screen

        img = Image(source = self.welcomeImage) #BACKGROUND IMAGE
        img.size = (Window.width*1.0, Window.height*1.0)
        img.pos = (-Window.width*0.0, -Window.height*0.0)
        img.opacity = 1.0 #alpha value between 0.0 - 1.0
        self.add_widget(img) #adds the image to the screen

        startBtn = MyButton(text = '') #start button
        startBtn.size_hint = (.21, .09)
        startBtn.pos_hint ={'x': .395, 'y': .24}
        startBtn.background_color = [.306, .325, .4196, .4] #backgroundcolor of the button (this is grayish)
        startBtn.bind(on_release = self.changer) #when the button is released the changer function is called
        self.add_widget(startBtn) #adds the button called startButton to the floatlayout

        aboutBtn = MyButton(text = '') #about button
        aboutBtn.size_hint = (.08, .095)
        aboutBtn.pos_hint ={'x': .618, 'y': 0}
        aboutBtn.background_color = [.4, .4, .4, .4]
        aboutBtn.bind(on_release = self.about) #when the button is released the about function is called
        self.add_widget(aboutBtn) #adds the button called aboutBtn to the floatlayout

        uiowaBtn = MyButton(text = '') #uiowa button
        uiowaBtn.size_hint = (.08, .095)
        uiowaBtn.pos_hint = {'x':.7, 'y': 0}
        uiowaBtn.background_color = [.4, .4, .4, .4]
        uiowaBtn.bind(on_release = self.uiowa) #when the button is released the uiowa function is called
        self.add_widget(uiowaBtn) #adds the button called uiowaBtn to the floatlayout
GravBoxMaster.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(MyButton, self).__init__(**kwargs)
        self.font_size = Window.width*0.015 #setting font size
GravBoxMaster.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(WelcomeScreen, self).__init__(**kwargs)

        layout = FloatLayout() #Float Layout for positioning buttons and image anywhere on the screen
        layout.width = Window.width #the float layout is the size of the window
        layout.height = Window.height
        layout.x = Window.width/2 - layout.width/2 #sets the x position of the layout to 0
        layout.y = Window.height/2 - layout.height/2 #sets the y position of the layout to 0
        self.add_widget(layout) #adds the layout to the screen

        img = Image(source = self.welcomeImage) #BACKGROUND IMAGE
        img.size = (Window.width*1.0, Window.height*1.0)
        img.pos = (-Window.width*0.0, -Window.height*0.0)
        img.opacity = 1.0 #alpha value between 0.0 - 1.0
        self.add_widget(img) #adds the image to the screen

        startBtn = MyButton(text = '') #start button
        startBtn.size_hint = (.21, .09)
        startBtn.pos_hint ={'x': .395, 'y': .24}
        startBtn.background_color = [.4, .4, .4, .4] #backgroundcolor of the button (this is grayish)
        startBtn.bind(on_release = self.changer) #when the button is released the changer function is called
        self.add_widget(startBtn) #adds the button called startButton to the floatlayout

        aboutBtn = MyButton(text = '') #about button
        aboutBtn.size_hint = (.08, .095)
        aboutBtn.pos_hint ={'x': .618, 'y': 0}
        aboutBtn.background_color = [.4, .4, .4, .4]
        aboutBtn.bind(on_release = self.about) #when the button is released the about function is called
        self.add_widget(aboutBtn) #adds the button called aboutBtn to the floatlayout

        uiowaBtn = MyButton(text = '') #uiowa button
        uiowaBtn.size_hint = (.08, .095)
        uiowaBtn.pos_hint = {'x':.7, 'y': 0}
        uiowaBtn.background_color = [.4, .4, .4, .4]
        uiowaBtn.bind(on_release = self.uiowa) #when the button is released the uiowa function is called
        self.add_widget(uiowaBtn) #adds the button called uiowaBtn to the floatlayout
GravBoxMaster.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(AboutScreen, self).__init__(**kwargs)

        layout = FloatLayout()
        layout.width = Window.width
        layout.height = Window.height
        layout.x = Window.width/2 - layout.width/2
        layout.y = Window.height/2 - layout.height/2
        self.add_widget(layout)

        img = Image(source = self.aboutImage)
        img.size = (Window.width*1.0, Window.height*1.0)
        img.pos = (-Window.width*0.0, -Window.height*0.0)
        img.opacity = 0.4
        self.add_widget(img)

        aboutText = Label(text= 'GravBox is the interface application for the Augmented Reality (AR) Sandbox for gravitational dynamics simulations designed and built\nby Dr. Hai Fu\'s Introduction to Astrophysics class during the 2016-2017 academic year and beyond.\nGravBox itself was designed by Zachary Luppen, Erin Maier, and Mason Reed.\n\nAR Sandbox is the result of an NSF-funded project on informal science education for freshwater lake and watershed science developed by the\nUC Davis\' W.M. Keck Center for Active Visualization in the Earth Sciences (KeckCAVES),\ntogether with the UC Davis Tahoe Environmental Research Center, Lawrence Hall of Science, and ECHO Lake Aquarium and Science Center.', halign='center', valign='center')
        aboutText.pos = (.25, .25)
        self.add_widget(aboutText)

        backBtn = MyButton(text = 'BACK') # back button
        backBtn.size_hint = (.1, .1)
        backBtn.pos_hint ={'x': 0, 'y': .90}
        backBtn.background_color = [.4, .4, .4, 1]
        backBtn.bind(on_release = self.backButton) #when the button is released the callback function is called
        self.add_widget(backBtn)
GravBoxMaster.py 文件源码 项目:GravBox 作者: GravBoxInterface 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(UiowaScreen, self).__init__(**kwargs)

        layout = FloatLayout()
        layout.width = Window.width
        layout.height = Window.height
        layout.x = Window.width/2 - layout.width/2
        layout.y = Window.height/2 - layout.height/2
        self.add_widget(layout)

        img = Image(source = self.uiowaImage)
        img.size = (Window.width*1.0, Window.height*1.0)
        img.pos = (-Window.width*0.0, -Window.height*0.0)
        img.opacity = 0.4
        self.add_widget(img)

        aboutText = Label(text='UIOWA INFO HERE')
        aboutText.pos = (.25, .25)
        self.add_widget(aboutText)

        backBtn = MyButton(text = 'BACK') #start button
        backBtn.size_hint = (.1, .1)
        backBtn.pos_hint ={'x': 0, 'y': .9}
        backBtn.background_color = [.4, .4, .4, 1]
        backBtn.bind(on_release = self.backButton) #when the button is released the backButton function is called
        layout.add_widget(backBtn)
main.py 文件源码 项目:osava 作者: osava-nsit 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def display_error(grid, error, box_height='400dp'):
    error_box = BoxLayout(orientation='horizontal', size_hint_y=None, height=box_height)
    error_label = Label(text="Bad Input:\n" + error, size_hint_x=None, width=Window.width, valign='top', halign='center')
    # error_label.text_size = error_label.size
    error_box.add_widget(error_label)
    grid.add_widget(error_box)
    return error_box

# Main Menu Screen with options to choose an OS Algorithm
main.py 文件源码 项目:osava 作者: osava-nsit 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def add_process(self, chart_wid, mem_box, size_box, start_height, process_name, mem_start, rect_width, *args):
        # print "Drawing {} rectangle from {} to {}".format(process_name, mem_start, rect_width)
        with chart_wid.canvas:
            label = Label(text=process_name, size_hint_x=None, width=rect_width*self.inc)
            mem_box.add_widget(label)

            s_label = Label(text=str(mem_start), size_hint_x=None, width=rect_width*self.inc, halign='left', valign='top')
            s_label.text_size = s_label.size
            size_box.add_widget(s_label)

            Color(self.colors[process_name][0], self.colors[process_name][1], self.colors[process_name][2], 0.4, mode='rgba')
            Rectangle(pos=(self.margin_left+(mem_start*self.inc), start_height+self.margin_bottom), size=(rect_width*self.inc, kivy.metrics.dp(35)))
main.py 文件源码 项目:osava 作者: osava-nsit 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def draw_memory_state(self, mem_box, page_fault_box, temp_memory, *args):
        page_number = temp_memory['page_number']
        page_fault = temp_memory['page_fault']
        allocated_frame = temp_memory['frame_number']
        memory_state = temp_memory['memory_frames']

        mem_label = Label(text='', size_hint_x=None, width=self.margin_left - kivy.metrics.dp(25), valign='middle', halign='center')
        mem_label.text_size = mem_label.size
        mem_box.add_widget(mem_label)
        mem_label = Label(text='Memory state: ', size_hint_x=None, width=self.margin_left + kivy.metrics.dp(35), valign='middle', halign='left')
        mem_label.text_size = mem_label.size
        mem_box.add_widget(mem_label)

        for idx, state in enumerate(memory_state):
            if state == -1:
                state = 'X'
            if allocated_frame - 1 == idx and page_fault == 1:
                mem_label = ColoredBorderedLabel(text='[b][color=DEC41B]'+str(state)+'[/color][/b]', markup=True, size_hint_x=None, width=self.frame_width, valign='middle', halign='center')
            else:
                mem_label = WhiteBorderedLabel(text=str(state), size_hint_x=None, width=self.frame_width, valign='middle', halign='center')

            mem_label.text_size = mem_label.size
            mem_box.add_widget(mem_label)

        # To add page fault (Y/N)
        page_f_label = Label(text='', size_hint_x=None, width=self.margin_left - kivy.metrics.dp(25), valign='middle', halign='center')
        page_f_label.text_size = page_f_label.size
        page_fault_box.add_widget(page_f_label)

        page_f_label = Label(text='Page fault: ', size_hint_x=None, width=self.margin_left, valign='middle', halign='center')
        page_f_label.text_size = page_f_label.size
        page_fault_box.add_widget(page_f_label)

        if page_fault == 1:
            page_f_label = Label(text='[color=DEC41B]Yes[/color]', markup=True, size_hint_x=None, width=self.margin_left, valign='middle', halign='left')
        else:
            page_f_label = Label(text='No', markup=True, size_hint_x=None
                , width=self.margin_left, valign='middle', halign='left')
        page_f_label.text_size = page_f_label.size
        page_fault_box.add_widget(page_f_label)
main.py 文件源码 项目:osava 作者: osava-nsit 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def add_dashed_arrow(self, x1, y1, x2, y2, *args):
        with self.arrows_widget.canvas:
            Color(1, 1, 1)
            Line(points=[x1,y1,x2,y2], width=1, dash_length=kivy.metrics.dp(10), dash_offset=kivy.metrics.dp(20))

    # Drawing the arrow head
plugins.py 文件源码 项目:mobileinsight-mobile 作者: mobile-insight 项目源码 文件源码 阅读 66 收藏 0 点赞 0 评论 0
def __init__(self, **kw):
        """
        Initialization function. We will do the following task (in order):
        __[x] means already done in App__
            1. [x] Check if the device is rooted
            2. [x] Initialize necessary libs required by MobileInsight (e.g., libwireshark)
            3. [x] Check if Android's security policy allows MobileInsight to access diagnostic mode.
            This is mainly caused by SELinux
            4. [x] Create necessary folders on SDcard (e.g., /sdcard/mobileinsight/, /sdcard/mobileinsight/log/)
            5. Load built-in and 3rd-party plugins (located in /sdcard/mobileinsight/plugins/)
            6. [x] Check if the diagnostic mode is enabled
            7. Load configurations from the setting panel (configs stored in /sdcard/.mobileinsight.ini)
        """

        super(PluginsScreen, self).__init__(**kw)

        self.log_viewer = None

        self.plugins_list = get_plugins_list()

        self.terminal_stop = None
        self.terminal_thread = None
        bootup = True

        #used to shorten long widget names in popup menu
        shortenLabel = CoreLabel(markup = True, text_size = (Window.width/2.5, None), shorten_from = "right", font_size = 70)
        #Making and adding widgets to popup menu
        for name in self.plugins_list:
            widget = Button(id = name, markup = True, halign = "left", valign = "top", on_release = self.callback, background_normal = "", background_color = self.ids.selectButton.background_color)
            widget.text_size = (Window.width/2.25, Window.height/4)
            self.myLayout.add_widget(widget)

            app_path = self.plugins_list[name][0]
            if os.path.exists(os.path.join(app_path, "readme.txt")):
                with open(os.path.join(app_path, "readme.txt"), 'r') as ff:
                    my_description = ff.read()
            else:
                my_description = "no description."
            #shortening long widget names and making font size
            shortenedName = shortenLabel.shorten(name)
            font_size = "60"
            if Window.width < 1450:
                font_size = "45"
            widget.text = "[color=fffafa][size=70]"+ shortenedName + "[/size][size="+ font_size + "]\n"+ my_description+"[/size][/color]"

            if bootup:
                self.selectedPlugin = name
                self.ids.selectButton.text = "Select Plugin"
                bootup = False

        # register Broadcast Receivers.
        self.registerBroadcastReceivers()


问题


面经


文章

微信
公众号

扫码关注公众号