Example #1
0
    def __init__(self, **kwargs):
        super(Menu, self).__init__(**kwargs)
        global fullapp
        self.size = fullapp.size
        self.canvas.add(Color(1,1,1))
        LoginField = Widget()
        LoginField.orientation = 'vertical'
        LoginField.size = (Window.size[0]*0.7,Window.size[1]*0.23)
        LoginField.pos = (Window.size[0]*0.327,Window.size[1]*0.793)
        rect = Rectangle(size = LoginField.size,source = 'LoginWindow.png',pos = LoginField.pos)
        LoginField.canvas.add(rect)

        SomeLabel = Label(text='acc',color=(0,0,0,0.85),font_size=Window.size[1]*0.03,bold=True)
        SomeLabel.pos = (Window.size[0]*0.5,Window.size[1]*0.865)
        NickNameButton = Button(color=(0,0,0,1),font_size=Window.size[1]*0.034,bold=True)
        NickNameButton.pos = (Window.size[0]*0.4,Window.size[1]*0.88)
        NickNameButton.size = (Window.size[0]*0.55,Window.size[1]*0.064)
        NickNameButton.text = fullapp.get_user_name()
        NickNameButton.on_press = self.change_user
        NickNameButton.background_color = (0,0,0,0)

        LoginButton = Button(text = 'Pushers',color=(0.48,0.14,0.165,1),font_size=Window.size[1]*0.03,italic=True)
        LoginButton.background_color = (0,0,0,0)
        LoginButton.pos = (Window.size[0]*0.5,Window.size[1]*0.82)
        LoginButton.size = (Window.size[0]*0.38,Window.size[1]*0.064)
        LoginButton.on_press = self.notify

        LoginField.add_widget(SomeLabel)
        LoginField.add_widget(NickNameButton)
        LoginField.add_widget(LoginButton)
        self.LoginField = LoginField
        self.add_widget(LoginField) 
Example #2
0
    def __init__(self,**kwargs):
        super(Medicine,self).__init__(**kwargs)
        self.active_checkboxes = []
        self.checkboxeslist = []
        self.scrollsize = fullapp.size[0]*0.86,fullapp.size[1]*0.57
        self.scrollpos = fullapp.size[0]*0.07,fullapp.size[1]*0.34

        self.canvas.add(Rectangle(size=fullapp.size,pos=fullapp.pos,source="MainBackgroundWhiter.png"))
        self.add_widget(MenuButton())
        rect = Rectangle(size=(fullapp.size[0],fullapp.size[1]*0.236),pos=fullapp.pos,source='FrontForScroll.png')
        self.canvas.add(rect)
        self.canvas.add(Color(0.5,0.5,0.5,1))
        self.canvas.add(Rectangle(size=self.scrollsize,pos=self.scrollpos))

        MedScroll = ScrollView()
        MedScroll.size_hint = (None,None)
        MedScroll.size = self.scrollsize
        MedScroll.pos = self.scrollpos

        MedBox = Widget()
        MedBox.size_of_drug = (self.scrollsize[0],fullapp.size[1]*0.1)
        MedBox.spacing = fullapp.size[1]*0.01
        MedBox.size = (self.scrollsize[0],(MedBox.spacing+MedBox.size_of_drug[1])*len(IlnessBase.Medicine)-MedBox.spacing)
        MedBox.size_hint_y = None

        for i in range(len(IlnessBase.Medicine)):
            text = Label(color=(1,1,1,1),markup=True)
            text.text = IlnessBase.Medicine[i][:IlnessBase.Medicine[i].find(':')] + '  ' + '[i][size=11][color=272727]' + 'ATX num ' + IlnessBase.Medicine[i][IlnessBase.Medicine[i].find(':')+1:] + '[/i][/size][/color]'
            text.text_size = MedBox.size_of_drug
            text.text_size[0] -= MedBox.size_of_drug[1]
            text.halign = 'left'
            text.valign = 'middle'
            text.pos = (MedBox.size_of_drug[0]/4.3,i*(MedBox.spacing+MedBox.size_of_drug[1])-MedBox.size_of_drug[1]/2)
            b = Button(size=MedBox.size_of_drug,pos=(0,i*(MedBox.spacing+MedBox.size_of_drug[1])))
            b.bind(on_press=self.on_button)
            b.add_widget(text)
            checkbox = CheckBox(size=(MedBox.size_of_drug[1],MedBox.size_of_drug[1]),pos = (MedBox.size_of_drug[0]-MedBox.size_of_drug[1],i*(MedBox.spacing+MedBox.size_of_drug[1])))
            checkbox.num = i
            checkbox.bind(active=self.on_checkbox)
            b.add_widget(checkbox)
            self.checkboxeslist.append(checkbox)
            b.ATXNum = IlnessBase.Medicine[i][IlnessBase.Medicine[i].find(':')+1:]
            MedBox.add_widget(b)

        TopLabel = Label(bold=True,size_hint=(None,None),text='check prep:',font_size=fullapp.size[1]*0.036,color = (0,0,0,1),pos = (fullapp.size[0]*0.34,fullapp.size[1]*0.85))
        
        self.SomeWidget = Widget(pos=(0,0),size_hint=(None,None),size = fullapp.size)
        CancelButton = Button(text = 'exit',font_size=fullapp.size[1]*0.022,size_hint=(None,None),size=(MedBox.size_of_drug[0]/2.01,fullapp.size[1]*0.05),
            pos = (self.scrollpos[0],self.scrollpos[1]-fullapp.size[1]*0.05-1),background_color = (0.3,0.3,0.9,1),on_press=self.on_cancel)
        OkButton = Button(text = 'chose',font_size=fullapp.size[1]*0.022,size_hint=(None,None),size=(MedBox.size_of_drug[0]/2.01,fullapp.size[1]*0.05),
            pos = (self.scrollpos[0]+MedBox.size_of_drug[0]/2+1,self.scrollpos[1]-fullapp.size[1]*0.05-1),background_color = (0.3,0.3,0.9,1),on_press=self.on_choose)
        
        self.SomeWidget.add_widget(CancelButton)
        self.SomeWidget.add_widget(OkButton)
        self.SomeWidget.opacity=0

        MedScroll.add_widget(MedBox)
        self.add_widget(self.SomeWidget)
        self.add_widget(MedScroll)
        self.add_widget(TopLabel)
Example #3
0
	def build(self):
		#create window
		root = Widget()
		root.size = Window.size
		root.center = Window.center

		#create map
		Map.tileSet = TileFactory
		board = Map(size=(504,504))
		root.add_widget(board.getDisplayRoot())

		#add starting tile
		tile_fact = TileFactory()
		for i in range(1):
			btn = tile_fact.newTile(board)
			board.addPiece(btn,(i*126,i*126))

		#create players
		CurrentTile.map = board
		CurrentTile.tile_size = TileFactory.size

		playerTile = CurrentTile()
	
		newTile = tile_fact.newTile(board)
		root.add_widget(playerTile)

		playerTile.resetTile(newTile)

		return root
 def build(self):
     widget = Widget()
     widget.size = Window.size
     #Kivy不提供专门的图形绘制函数,而是采用组件与绘制分离模式,这样,可以在任何地方实现图形绘制。
     with widget.canvas:
         #设置颜色
         Color(255, 255, 255)
         #绘制一个与Widget一样大小的矩形
         Rectangle(pos=widget.pos, size=widget.size)
         Color(255, 255, 0)
         Line(points=[0, 0, widget.size[0], widget.size[1]], width=5)
         print(widget.size)
     return widget
Example #5
0
 def build(self):
     widget = Widget()
     #2. 使用on_<属性名>绑定一个事件方法。
     widget.on_size = self.changeSize()
     #3.改变size会触发change方法的调用。
     widget.size = (
         Window.size[0] / 2,
         Window.size[1] / 2,
     )
     with widget.canvas:
         Color(0, 255, 255)
         Rectangle(pos=widget.pos, size=widget.size)
     return widget
Example #6
0
    def create_literature(self):
        global fullapp,butsize,chartsize,spacing
        butsize = (self.scrollsize[0],fullapp.size[1]*0.1)
        spacing = fullapp.size[1]*0.03
        chartsize = (fullapp.size[0]*0.68,fullapp.size[1]*0.1)
        symbols_to_fill = 50
        
        image = Widget()
        image.size = (fullapp.size[0]*0.68,self.find_height(len(self.opened_divisions))+self.find_chartsize(self.opened_divisions[-1])[1]*self.opened_divisions[-1])
        image.size_hint_y = None

        for i in range(len(self.opened_divisions)):

            CurBaseElement = copy.copy(IlnessBase.Literature[IlnessBase.LiteratureKeys[i]])
            CurSource = 'ButtonForLiterature.png' if (self.opened_divisions[i] == 0) else 'ButtonForLiteratureClicked.png'
            image.canvas.add(Rectangle(size = butsize,pos = (0,image.size[1] - self.find_height(i+1)),source = CurSource))
            label = Label(text = '[color=ffffff]'+str(IlnessBase.LiteratureKeys[i])+'[/color]', markup = True, bold =True, italic = True, font_size = fullapp.size[1]*0.04)
            label.text_size=butsize
            label.halign = 'left'
            label.pos = (fullapp.size[0]*0.32,image.size[1] - self.find_height(i+1) - fullapp.size[1]*0.02)
            image.add_widget(label)

            button = Button(size = butsize,pos = (0,image.size[1] - self.find_height(i+1)),background_color = (1,1,1,0))
            button.num = i
            button.bind(on_press = self.on_button)
            image.add_widget(button)

            if(self.opened_divisions[i] == 1):
                rectpos =  (fullapp.size[0]*0.13,image.size[1] - self.find_height(i+1) - self.find_chartsize(i)[1])
                image.canvas.add(Rectangle(size = self.find_chartsize(i),pos = rectpos,source = 'GreySquare.png'))
                for j in range(len(CurBaseElement)):
                    if(len(CurBaseElement[j]) < symbols_to_fill/1.4):
                        CurBaseElement[j] = CurBaseElement[j][:CurBaseElement[j].find(':')] + ':' +' '*20 + CurBaseElement[j][CurBaseElement[j].find(':')+1:]

                    ChartLabel = Label(text='* ' + CurBaseElement[j][:CurBaseElement[j].find(':')] + '[i]'+CurBaseElement[j][CurBaseElement[j].find(':'):] + '[/i]',
                        text_size = (chartsize[0]*1,chartsize[1]),font_size=chartsize[1]/3.36,markup = True,color = (0.17,0.17,0.17,1),
                        pos = (chartsize[0]/2-fullapp.size[0]*0.017,image.size[1] - self.find_height(i+1)-chartsize[1]*(j+1.4)))
                    image.add_widget(ChartLabel)
        return image
Example #7
0
    def build(self):
        self.title = 'テスト'

        layout = Widget()
        layout.size = Window.size

        # image = Image.open('./monitor-1.png')
        with mss() as sct:
            rect = {'top': 0, 'left': 0, 'width': WIDTH, 'height': HEIGHT}
            sct_img = sct.grab(rect)
            image = Image.frombytes("RGB", sct_img.size, sct_img.bgra, "raw",
                                    "BGRX")

        texture = Texture.create(size=image.size)
        texture.blit_buffer(image.tobytes())
        texture.flip_vertical()
        with layout.canvas.before:
            layout.rect = Rectangle(texture=texture,
                                    pos=layout.pos,
                                    size=layout.size)

        return layout
Example #8
0
    def notify(self):
        def exit(instance):
            self.remove_widget(NotePopup)

        self.scrollsize = fullapp.size[0]*0.8,fullapp.size[1]*0.6
        self.scrollpos = fullapp.size[0]*0.095,fullapp.size[1]*0.185
        self.size_of_note = (self.scrollsize[0],fullapp.size[1]*0.25)

        NotePopup = Popup(size_hint=(None,None),size=(fullapp.size[0]*0.9,fullapp.size[1]*0.8))
        NotePopup.pos = (fullapp.size[0]/2 - NotePopup.size[0]/2,fullapp.size[1]/2 - NotePopup.size[1]/2)
        NotePopup.title = 'view pushers.'
        NotePopup.title_align = 'center'
        NotePopup.separator_color = (0.3,0.3,1,1)
        NotePopup.title_size = fullapp.size[1]*0.03

        NoteScroll = ScrollView()
        NoteScroll.size_hint = (None,None)
        NoteScroll.size = self.scrollsize
        NoteScroll.pos =self.scrollpos

        NoteBox = Widget()
        NoteBox.size_of_note = self.size_of_note
        NoteBox.spacing = fullapp.size[1]*0.006
        NoteBox.size = (self.scrollsize[0],(NoteBox.spacing+NoteBox.size_of_note[1])*len(fullapp.notes)-NoteBox.spacing)
        NoteBox.size_hint_y = None

        for i in range(len(fullapp.notes)):
            b = Button(size=self.size_of_note,pos=(-2,i*(NoteBox.spacing+NoteBox.size_of_note[1])))
            
            if(fullapp.notes[i]['type'] == 'request'):
                b.add_widget(Label(markup=True,text='[color=cccccc]'+'ok request number '+ '[b][/color]' + str(fullapp.notes[i]['idnum']) + '[/b]',font_size=fullapp.size[1]*0.03,color=(1,1,1,1),pos=(fullapp.size[0]*0.19,fullapp.size[1]*0.126+i*(NoteBox.spacing+NoteBox.size_of_note[1]))))
                if(fullapp.notes[i]['undertype']=='med'):
                    preparate =  IlnessBase.Medicine[fullapp.notes[i]['idinIlnessBase']]
                    print(preparate)
                    b.add_widget(Label(text_size=(self.size_of_note[0]*0.97,self.size_of_note[1]*0.7),markup=True,text='to adding preparate '+ '[b][i]' + preparate[:preparate.find(':')]\
                         + '[/b][/i]'+' seems ' + '[b][i]' + preparate[preparate.find(':')+1:] + '[/b][/i]'+' by systemATX.',font_size=fullapp.size[1]*0.03,color=(1,1,1,1),pos=(fullapp.size[0]*0.244,fullapp.size[1]*0.086+i*(NoteBox.spacing+NoteBox.size_of_note[1]))))
                    
                    if(fullapp.notes[i]['state']=='inprogress'):
                        b.add_widget(Label(text='[color=cccccc]Poss: [/color][b][color=adaddf]cheking[/color][b]',font_size=fullapp.size[1]*0.03,markup=True,pos=(fullapp.size[0]*0.184,-fullapp.size[1]*0.046+i*(NoteBox.spacing+NoteBox.size_of_note[1]))))

                    b.add_widget(Label(text='[color=353535]from '+ fullapp.notes[i]['date'],markup=True,font_size=fullapp.size[1]*0.025,pos=(fullapp.size[0]*0.384,-fullapp.size[1]*0.076+i*(NoteBox.spacing+NoteBox.size_of_note[1]))))
                
                elif(fullapp.notes[i]['undertype']=='ser'):
                    service =  fullapp.notes[i]['name']
                    print(service)
                    b.add_widget(Label(text_size=(self.size_of_note[0],self.size_of_note[1]*0.7),markup=True,text='To add new usluga '+ '[b][i]' + service\
                         + '[/b][/i]'+ '[/b][/i]'+'.   Check info to usluga.',font_size=fullapp.size[1]*0.03,color=(1,1,1,1),pos=(fullapp.size[0]*0.244,fullapp.size[1]*0.056+i*(NoteBox.spacing+NoteBox.size_of_note[1]))))
                    
                    if(fullapp.notes[i]['state']=='inprogress'):
                        b.add_widget(Label(text='[color=cccccc]Statust: [/color][b][color=adaddf]checking[/color][b]',font_size=fullapp.size[1]*0.03,markup=True,pos=(fullapp.size[0]*0.184,-fullapp.size[1]*0.046+i*(NoteBox.spacing+NoteBox.size_of_note[1]))))

                    b.add_widget(Label(text='[color=353535]from '+ fullapp.notes[i]['date'],markup=True,font_size=fullapp.size[1]*0.025,pos=(fullapp.size[0]*0.384,-fullapp.size[1]*0.076+i*(NoteBox.spacing+NoteBox.size_of_note[1]))))
            
            NoteBox.add_widget(b)

        DefendWidget = Widget(size=fullapp.size,pos=fullapp.pos,size_hint=(None,None))
        NoteScroll.add_widget(NoteBox)
        DefendWidget.add_widget(NoteScroll)
        DefendWidget.add_widget(Button(size_hint=(None,None),pos=(fullapp.size[0]*0.11,fullapp.size[1]*0.13),size=(25,25),background_normal='47.png',on_press=exit))
        if(len(fullapp.notes)==0):
            DefendWidget.add_widget(Label(text='Non pushers',pos=(self.scrollpos[0]+self.scrollsize[0]/3.6,self.scrollpos[1]+self.scrollsize[1]/2),font_size=fullapp.size[1]*0.04))
        else:
            DefendWidget.add_widget(Label(text_size=(fullapp.size[0]*0.7,100),text='[color=010101]view in [b] http://www.sechenovclinic.ru/[/color][/b]',font_size=fullapp.size[1]*0.02,pos=(self.scrollpos[0]+self.scrollsize[0]/2.7,self.scrollpos[1]-fullapp.size[1]*0.047),markup=True))
        NotePopup.add_widget(DefendWidget)
        self.add_widget(NotePopup)
def test_no_parent():
    from kivy.uix.widget import Widget
    from kivy_garden.draggable import \
        save_widget_location, restore_widget_location
    w = Widget()
    location = save_widget_location(w)
    assert location == {
        'x': 0,
        'y': 0,
        'width': 100,
        'height': 100,
        'size_hint_x': 1,
        'size_hint_y': 1,
        'pos_hint': {},
        'size_hint_min_x': None,
        'size_hint_min_y': None,
        'size_hint_max_x': None,
        'size_hint_max_y': None,
    }
    w.pos = [
        20,
        20,
    ]
    w.size = [
        40,
        40,
    ]
    w.size_hint = [
        None,
        None,
    ]
    w.pos_hint = {
        'x': 1,
        'top': .5,
    }
    w.size_hint_min = [
        30,
        30,
    ]
    w.size_hint_max = [
        70,
        70,
    ]
    restore_widget_location(w, location)
    assert w.size == [
        100,
        100,
    ]
    assert w.pos == [
        0,
        0,
    ]
    assert w.size_hint == [
        1,
        1,
    ]
    assert w.pos_hint == {}
    assert w.size_hint_min == [
        None,
        None,
    ]
    assert w.size_hint_max == [
        None,
        None,
    ]
    def drawObj(self, obj=None):
        '''
        Updates a object if object already on widget.
        Otherwise it will create a object
        Override this function to create your own
        apperance of ojects
        '''        
        assert isinstance(obj, mrGraphicsObject)

        if type(obj) == None:
            return False

        # get obj attributes
        objID = obj.getID()
        objname = obj.getName()
        location = self.convertPosition( obj.getLocation() )
        color = obj.getColor()
        wObj = None
        
        # draw objects
        with self.canvas:
            # set color
            Color( color[0], color[1], color[2], color[3] )
            
            if type(obj) == mrGraphicsBot:
                # draw bot
                assert isinstance(obj, mrGraphicsBot)
                size = self.convertSize( obj.getSize() )
                angle = obj.getAngle()
                lineW, points, points2, corners = self.getBotDrawData(location, size)
                print "points", points, points2
                p0 = corners[0]
                p3 = corners[3]

                # draw object
                wObj = {'widget': Widget( pos=p0 ), 'label': None}
                lbl = Label( text=str(objID)+":"+objname, pos=p3 )
                lbl.texture_update()
                tsize = lbl.texture.size
                lbl.size = (tsize[0], tsize[1])
                wObj['label'] = lbl
                
                # draw dot
                with wObj['widget'].canvas.before:
                    PushMatrix()
                    Rotate( angle=angle, axis=(0,0,1), origin=(location[0], location[1], 0) )                        
                with wObj['widget'].canvas.after:
                    PopMatrix()
                                            
                with wObj['widget'].canvas:
                    Color( color[0], color[1], color[2], color[3] )
                    Line( points=points, width=lineW )
                    Line( points=points2, width=lineW )
                   
                if angle != 0: 
                    with wObj['label'].canvas.before:
                        PushMatrix()
                        Rotate( angle=angle, axis=(0,0,1), origin=(location[0], location[1], 0) )                        
                    with wObj['label'].canvas.after:
                        PopMatrix()
                        
                        
            
            if type(obj) == mrGraphicsRectangle:
                # draw rectangle  
                assert isinstance(obj, mrGraphicsRectangle)
                size = self.convertSize( obj.getSize() )              
                pos = ( location[0]-size[0]/2, location[1]-size[1]/2 )
                angle = obj.getAngle()
                
                # draw new object
                wObj = Widget( size=size, pos=pos )
                
                # draw rectangle
                with wObj.canvas:
                    Color( color[0], color[1], color[2], color[3] )
                    Rectangle( size=size, pos=pos )
                    
                if angle != 0:
                    with wObj.canvas.before:
                        PushMatrix()
                        Rotate( angle=angle, axis=(0,0,1), origin=(location[0], location[1], 0) )                        
                    with wObj.canvas.after:
                        PopMatrix()                   


            if type(obj) == mrGraphicsLine:
                #draw line
                assert isinstance(obj, mrGraphicsLine)
                points = self.convertPoints( obj.getPoints() )
                width = self.convertSize( obj.getWidth() )       
                
                # draw new object
                wObj = Line( points=points, width=width )
            
            
            if type(obj) == mrGraphicsDot:
                #draw dot
                assert isinstance(obj, mrGraphicsDot)
                radius = self.convertSize( obj.getRadius() )
                size = (2*radius, 2*radius)
                pos = ( location[0]-radius, location[1]-radius  )
                
                # draw new object
                wObj = Ellipse( pos=pos, size=size  )
            
            
            if type(obj) == mrGraphicsCircle:
                #draw cricle
                assert isinstance(obj, mrGraphicsCircle)
                radius = self.convertSize( obj.getRadius() )
                width = self.convertSize( obj.getWidth() )
                
                # draw new object
                wObj = Line( circle=(location[0], location[1], radius), width=width )
                    
                    
            if type(obj) == mrGraphicsText:
                #draw text
                assert isinstance(obj, mrGraphicsText)
                text = obj.getText()
                textcolor = obj.getTextColor()
                fontsize = obj.getFontSize()
                angle = obj.getAngle()
                
                # draw new object
                padding = 5
                wObj = Label( text=text, pos=location, markup=True, color=textcolor )
                if fontsize != None:
                    print "set fontsize", fontsize
                    wObj.font_size = fontsize
                
                wObj.texture_update()
                size = wObj.texture.size
                wObj.size = (size[0]+2*padding, size[1]+2*padding)
                 
                with wObj.canvas.before:                        
                    PushMatrix()
                    Rotate( angle=angle, axis=(0,0,1), origin=(location[0], location[1], 0) )  
                    Color( color[0], color[1], color[2], color[3] )
                    Rectangle( pos=wObj.pos, size=wObj.size)   
                                            
                with wObj.canvas.after:                        
                    PopMatrix()
                        
                        
            if type(obj) == mrGraphicsImage:
                # draw image
                assert isinstance(obj, mrGraphicsImage)
                src = obj.getSource()
                keepRatio = obj.keepRatio()
                size = self.convertSize( obj.getSize() )                
                angle = obj.getAngle()
                
                if isfile(src):
                    wObj = AsyncImage( source=src, size=size, allow_stretch=True, keep_ratio=keepRatio )
                    wObj.texture_update()
                    pos = (location[0]-size[0]*0.5, location[1]-size[1]*0.5)
                    wObj.pos = pos
                    size = wObj.size
                    
                    if angle != 0:
                        with wObj.canvas.before:
                            PushMatrix()
                            Rotate( angle=angle, axis=(0,0,1), origin=(location[0], location[1], 0) )
                                                    
                        with wObj.canvas.after:
                            PopMatrix()
            
        # send update request to canvas
        self.canvas.ask_update()
        
        # return new object
        return wObj