예제 #1
0
class TestTextField(TestCase):
    def setUp(self) -> None:
        self.test_field = TextField()
        self.valid_char_num = randint(1001, 3000)
        self.invalid_char_num = randint(0, 999)
        self.valid_text = gen_random_text(self.valid_char_num)
        self.invalid_text = gen_random_text(self.invalid_char_num)

    def test_valid_text_field(self):
        self.assertTrue(self.test_field.is_valid(self.valid_text))

    def test_invalid_text_field(self):
        self.assertFalse(self.test_field.is_valid(self.invalid_text))
예제 #2
0
class ExampleModelWithFk(Model):
    __tablename__ = 'example_model_with_fk'

    id = PrimaryKeyField()
    integer_field = IntegerField()
    text_field = TextField()
    fk_field = ForeignKey(to=SimpleExampleModel)
예제 #3
0
 def on_touch_move(self, touch):
     if self.selected and touch.grab_current == self:
         for c in self.layout_maker.selections:
             if c == self:
                 continue
             c.x += touch.dx
             c.y += touch.dy
         return TextField.on_touch_move(self, touch)
     return False
예제 #4
0
 def on_touch_move(self, touch):
     if self.selected and touch.grab_current == self:
         for c in self.layout_maker.selections:
             if c == self:
                 continue
             c.x += touch.dx
             c.y += touch.dy
         return TextField.on_touch_move(self, touch)
     return False
예제 #5
0
class Comment(Model):
    __table__ = 'comments'

    id = StringField(primary_key=True, default=next_id, ddl='varchar(50)')
    blog_id = StringField(ddl='varchar(50)')
    user_id = StringField(ddl='varchar(50)')
    user_name = StringField(ddl='varchar(50)')
    user_image = StringField(ddl='varchar(500)')
    content = TextField()
    created_at = FloatField(default=time.time)
예제 #6
0
class Blog(Model):
    __table__ = 'blogs'

    id = StringField(primary_key=True, default=next_id, ddl='varchar(50)')
    user_id = StringField(ddl='varchar(50)')
    user_name = StringField(ddl='varchar(50)')
    user_image = StringField(ddl='varchar(500)')
    name = StringField(ddl='varchar(50)')
    summary = StringField(ddl='varchar(200)')
    content = TextField()
    created_at = FloatField(default=time.time)
예제 #7
0
def input_text(prompt, width, initial=None, **kwds):
    box = Dialog(**kwds)
    d = box.margin

    def ok():
        box.dismiss(True)

    def cancel():
        box.dismiss(False)

    lb = Label(prompt)
    lb.topleft = (d, d)
    tf = TextField(width)
    if initial:
        tf.set_text(initial)
    tf.enter_action = ok
    tf.escape_action = cancel
    tf.top = lb.top
    tf.left = lb.right + 5
    box.add(lb)
    box.add(tf)
    tf.focus()
    box.shrink_wrap()
    if box.present():
        return tf.get_text()
    else:
        return None
예제 #8
0
def BasicTextInputRow(title, *args, **kw):
    return Row(
        (Label(title,
               tooltipText=kw.get('tooltipText')), TextField(*args, **kw)))
예제 #9
0
def input_text_buttons(prompt, width, initial=None, **kwds):
    box = Dialog(**kwds)
    d = box.margin

    def ok():
        box.dismiss(True)

    def cancel():
        box.dismiss(False)

    buts = []
    buts.append(Button("OK", action=ok))
    buts.append(Button("Cancel", action=cancel))

    brow = Row(buts, spacing=d)

    lb = Label(prompt)
    lb.topleft = (d, d)
    tf = TextField(width)
    if initial:
        tf.set_text(initial)
    tf.enter_action = ok
    tf.escape_action = cancel
    tf.top = lb.top
    tf.left = lb.right + 5

    trow = Row([lb, tf], spacing=d)

    col = Column([trow, brow], spacing=d, align='c')

    col.topleft = (d, d)

    box.add(col)
    tf.focus()
    box.shrink_wrap()
    if box.present():
        return tf.get_text()
    else:
        return None
예제 #10
0
class SimpleExampleModel(Model):

    id = PrimaryKeyField()
    integer_field = IntegerField()
    text_field = TextField(required=False)
    required_text_field = TextField(required=True)
예제 #11
0
 def setUp(self) -> None:
     self.test_field = TextField()
     self.valid_char_num = randint(1001, 3000)
     self.invalid_char_num = randint(0, 999)
     self.valid_text = gen_random_text(self.valid_char_num)
     self.invalid_text = gen_random_text(self.invalid_char_num)