Форум сайта python.su
Есть программа на python kivy. При запуске из терминала она зависает на
mike@mike-MS-7740:/media/mike/189860AB98608958/mike2804/Документы/bot/codes$ python3 interface.py [INFO ] [Logger ] Record log in /home/mike/.kivy/logs/kivy_19-07-18_20.txt [INFO ] [Kivy ] v1.11.1 [INFO ] [Kivy ] Installed at "/usr/local/lib/python3.6/dist-packages/kivy/__init__.py" [INFO ] [Python ] v3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] [INFO ] [Python ] Interpreter at "/usr/bin/python3" [INFO ] [Logger ] Purge log fired. Analysing... [INFO ] [Logger ] Purge 2 log files [INFO ] [Logger ] Purge finished! [INFO ] [Factory ] 184 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Text ] Provider: sdl2 [INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored) [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] Backend used <sdl2> [INFO ] [GL ] OpenGL version <b'3.1 Mesa 19.0.2'> [INFO ] [GL ] OpenGL vendor <b'X.Org'> [INFO ] [GL ] OpenGL renderer <b'AMD BARTS (DRM 2.50.0 / 4.18.0-25-generic, LLVM 8.0.0)'> [INFO ] [GL ] OpenGL parsed version: 3, 1 [INFO ] [GL ] Shading version <b'1.40'> [INFO ] [GL ] Texture max size <16384> [INFO ] [GL ] Texture max units <16> [INFO ] [Window ] auto add sdl2 input provider [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked xclip version 0.12 Copyright (C) 2001-2008 Kim Saunders et al. Distributed under the terms of the GNU GPL [INFO ] [Clipboard ] Provider: xclip [INFO ] [CutBuffer ] cut buffer support enabled
mike@mike-MS-7740:/media/mike/189860AB98608958/mike2804/Документы/bot/codes$ python3 interface.py [INFO ] [Logger ] Record log in /home/mike/.kivy/logs/kivy_19-07-18_22.txt [INFO ] [Kivy ] v1.11.1 [INFO ] [Kivy ] Installed at "/usr/local/lib/python3.6/dist-packages/kivy/__init__.py" [INFO ] [Python ] v3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] [INFO ] [Python ] Interpreter at "/usr/bin/python3" [INFO ] [Factory ] 184 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored) [INFO ] [Text ] Provider: sdl2 [INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored) [INFO ] [GL ] Using the "OpenGL" graphics system [INFO ] [GL ] Backend used <sdl2> [INFO ] [GL ] OpenGL version <b'3.1 Mesa 19.0.2'> [INFO ] [GL ] OpenGL vendor <b'X.Org'> [INFO ] [GL ] OpenGL renderer <b'AMD BARTS (DRM 2.50.0 / 4.18.0-25-generic, LLVM 8.0.0)'> [INFO ] [GL ] OpenGL parsed version: 3, 1 [INFO ] [GL ] Shading version <b'1.40'> [INFO ] [GL ] Texture max size <16384> [INFO ] [GL ] Texture max units <16> [INFO ] [Window ] auto add sdl2 input provider [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked xclip version 0.12 Copyright (C) 2001-2008 Kim Saunders et al. Distributed under the terms of the GNU GPL [INFO ] [Clipboard ] Provider: xclip [INFO ] [CutBuffer ] cut buffer support enabled ^C[INFO ] [Base ] Start application main loop [INFO ] [GL ] NPOT texture support is available [INFO ] [WindowSDL ] exiting mainloop and closing. [INFO ] [Base ] Leaving application in progress...
from kivy.app import App from kivy.uix.button import Button from kivy.uix.textinput import TextInput from kivy.uix.floatlayout import FloatLayout from kivy.uix.gridlayout import GridLayout from kivy.config import Config import time import random import scenary import telebot Config.set('graphics', 'resizable', 0) Config.set('graphics', 'width', '260') Config.set('graphics', 'height', '360') #varibles run = 0 fl = FloatLayout() gl = GridLayout(cols=2, size_hint=(.95, .08), pos=(260/2/2/2/2/2/1.5, 360/2/2)) ti = TextInput(font_size=15,) #полле ввода шаблонов - сообщений start = Button(text="СТАРТ!!!", font_size=20, background_color=[0, 0, 1, 1], background_normal='', pos=(260/2/2, 360/3/3), size_hint=(.5, .10) )#кнопка "старт" Add = Button(text="Добавить", font_size=15, background_color=[0, 0, 1, 1], background_normal='', size_hint=(.45, .10), )#кнопка "добавить" save = Button(text="СОХРАНИТЬ", font_size=15, background_color=[0, 0, 1, 1], background_normal='', pos=(260/2/1.5, 360/1.5), size_hint=(.35, .10) )#кнопка "сохранить" rand1 = random.randint(60, 3540) randm = 0 bot = telebot.TeleBot('624792720:AAFwShnw2uzAZxjM2XWsxdl0DcV4bZ0qaWQ') #Подключение к нужному боту class myapp(App): def build(self): #метод былд отрисовывающий все виджеты fl.add_widget(gl) fl.add_widget(start) fl.add_widget(save) gl.add_widget(ti) gl.add_widget(Add) start.bind(on_press=self.btn_start_pressed) save.bind(on_press=self.btn_save_pressed) Add.bind(on_press=self.btn_add_pressed) return fl def btn_start_pressed(self, instance): #функция выполняемая при нажатии на кнопку "старт" self.send_text() if instance.text == "СТАРТ!!!": instance.text = "СТОП..." run = True else: instance.text = "СТАРТ!!!" run = False def btn_add_pressed(self, instance): #функция выполняемая при нажатии на кнопку "добавить" scenary.scen.append(ti.text) ti.text = "" def btn_save_pressed(self, instance): #функция выполняемая при нажатии на кнопку "сохранить" fi = open ('scenary.py', 'w') fi.write("scen = ") fi.write(str(scenary.scen)) fi.close() #конструкция отправки/принятия сообщений @bot.message_handler(content_types=['text', 'start']) #определение типа отправляемого сообщения def send_text(self): #функция отправляющяя сообщения while run == True: randm = random.choice(scenary.scen) rand1 = random.randint(60, 3540) bot.send_message(message.from_user.id, randm) time.sleep(rand1) bot.polling() if __name__ == '__main__': myapp().run()
Офлайн