# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
#!/usr/bin/python
import kivy
from kivy.app import App
from kivy.uix.textinput import TextInput
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
class RootWidget(GridLayout):
def __init__(self, **kwargs):
super(RootWidget, self).__init__(**kwargs)
self.cols = 2
self.add_widget(CreateInput(multiline=False))
class CreateInput(TextInput):
def on_text_validate(self):
for i in range(int(self.text)):
self.parent.add_widget(Button(text=str(i)))
class MyApp(App):
def build(self):
return RootWidget()
if __name__ == "__main__":
MyApp().run()
from kivy.uix.button import Button
from kivy.core.window import Window
class HLButton(Button):
def __init__(self, *args, **kwargs):
super(HLButton, self).__init__(*args, **kwargs)
Window.bind(mouse_pos=self.pos_check)
def pos_check(self, inst, pos):
if self.collide_point(*pos):
self.background_color = (1, 0, 0, 1)
else:
self.background_color = (.52, .43, .57, 1)
Kivy supports only one window per application: please don’t try to create more than one.
print(list(bs0bj.find("table").previous_siblings))
gl.add_widget( Button(text="AC", font_size=18, on_press=self.clear) )
, может быть? #!/usr/bin/python
from textblob import TextBlob
from textblob.classifiers import NaiveBayesClassifier
train1 = '''
Вася Пупкин
Менеджер
телефон 674847585748
адрес 523645653
'''
train2 = '''
Иван Иванов
Менеджер
телефон 673844589748
адрес 513665053
'''
train3 = '''
Николас Медведев
Менеджер
телефон 674947581748
адрес 526641655
'''
train = [
(train1, 'pos'),
(train2, 'pos'),
(train3, 'pos'),
('С уважением, от команды Хабра!', 'neg'),
('Купите наших котиков?', 'neg'),
('Скидки 120% но Aliexpress.', 'neg'),
]
test = '''
Привет!
Алиса Аксенова
Менеджер
телефон 678942581948
адрес 520671655
'''
cl = NaiveBayesClassifier(train)
blob = TextBlob(test, classifier=cl)
for s in blob.sentences:
print("'{}' - {}".format(s, s.classify()))
'Привет!' - neg
'Алиса Аксенова
Менеджер
телефон 678942581948
адрес 520671655' - pos