def place(self, selected=None, active=None):

        if active == None:
            self.active = 1
            active = 1  # turn on button

        if active:
            if selected == None:
                selected = self.selected

            if selected:
                cur_color = self.color_sel
                cur_text = self.text_color_sel
            else:
                cur_color = self.color
                cur_text = self.text_color

            #place base shape for button
            io.if_rect(self.x, self.y, self.width, self.height, self.radius,
                       cur_color)

            if self.text != ' ':
                #find/calc text dimension and location
                text_dim = io.text_dimensions(self.x, self.y, self.text)
                text_x = int(self.x + self.x_offset +
                             (self.width - text_dim[0]) / 2) - 1
                text_y = int(self.y + self.y_offset +
                             (self.height - text_dim[1]) / 2) - 1

                #place text
                io.text(text_x, text_y, self.text, cur_text, cur_color)
Exemplo n.º 2
0
def _button_error(but, message=None):
    if message == None:
        message = but.error_message

    io.if_rect(but.x, but.y, but.width, but.height, but.radius, io.red)
    io.text(but.x + but.radius, but.y + but.radius, message, background=io.red)

    time.sleep(1)
    but.place()
Exemplo n.º 3
0
 def sub_place(self):
     #width = io.text_dimensions(self.x+self.border,self.y+self.border,self.value)
     #io.rect(self.x+self.border + width,self.y+self.border, self.width - width, self.height)
     
     #place  rect to clear any place where new text won't go
     minx = self.width
     for line in self.value.split('\n'):
         minx = min(minx, io.text_dimensions(self.x,self.y,line)[0] )
     
     io.rect(self.x+self.border + minx, self.y+self.border, 
             self.width - self.border*2 - minx,
             self.height - self.border*2,
             self.background)
 
     io.text(self.x + self.border,self.y + 1 + self.border, self.value, color = self.color,
             background = self.background)
def _button_error(but):
    io.if_rect(but.x, but.y, but.width, but.height, but.radius, io.red)
    io.text(but.x + but.radius, but.y + but.radius, 'Err', background=io.red)
    time.sleep(1)
    but.place()