Итак, я создал приложение, которое использует панды и некоторые функции выбора для сохранения структур данных.Приложение отлично работает на моем MacBook, но когда я пытаюсь запустить его на своем galaxy s9 через Kivy Launcher, оно сразу вылетает, даже не доходя до GUI.У меня нет никакого способа понять, в чем проблема, поскольку я новичок, и у меня нет никаких исключений / ошибок, которые я обычно использую на своем ноутбуке.Может кто-нибудь взглянуть на мой код и сообщить мне, если я что-то не так делаю?
__version__ = '1.10.1'
from kivy.app import App
from kivy.app import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.properties import ObjectProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.slider import Slider
import pandas
import openpyxl
import pickle
#empty_dict = {} # use this code if the pickle file is corrupt and needs to be reset.
#pickle_out = open("dict.pickle", "wb")
#pickle.dump(empty_dict, pickle_out)
#pickle_out.close()
class MainWindow(Screen):
"""This class will serve as the front page of the application.
This input will be stored in a dictionary and later converted
to a data structure using pandas and openpyxl."""
# These variables link the python logic to the my2.kv kivy language file.
first_name = ObjectProperty(None)
last_name = ObjectProperty(None)
level = ObjectProperty(None)
# This section loads and saves the information stored from the user input.
pickle_in = open('dict.pickle', 'rb') # opens and assigns the opened pickle file to variable.
student_data = pickle.load(pickle_in) # imports the saved pickle file and assigns it to a variable.
pickle_in.close() # closes the pickle file for safety.
def btn(self):
print(MainWindow.student_data)
print("First: " + self.first_name.text,
"Last: " + self.last_name.text)
self.L = {self.first_name.text + ' ' + self.last_name.text: []}
MainWindow.student_data.update(self.L)
pickle_out = open("dict.pickle", "wb")
pickle.dump(MainWindow.student_data, pickle_out)
pickle_out.close()
self.first_name.text = ''
self.last_name.text = ''
class Controller(Screen):
def __init__(self, **kwargs):
super(Controller, self).__init__(**kwargs)
def btn2(self):
print(self.lbl.text)
print(self.lbl2.text)
print(self.lbl3.text)
print(self.lbl4.text)
print(self.first_last.text)
print(self.first_last2.text)
self.data = {self.first_last.text + ' ' + self.first_last2.text: [self.level.text, self.lbl.text, self.lbl2.text, self.lbl3.text, self.lbl4.text]}
print(self.data)
# This section loads and saves the information stored from the user input.
self.pickle_in = open('dict.pickle', 'rb') # opens and assigns the opened pickle file to variable.
self.loaded_data = pickle.load(self.pickle_in) # imports the saved pickle file and assigns it to a variable.
self.pickle_in.close() # closes the pickle file for safety.
print(self.loaded_data)
self.dictionary2 = self.data
self.dictionary1 = self.loaded_data
self.dictionary1.update(self.dictionary2)
print(self.dictionary1)
pickle_out = open("dict.pickle", "wb")
pickle.dump(self.dictionary1, pickle_out)
pickle_out.close()
self.first_last.text = ''
self.first_last2.text = ''
def Reading(self, *args):
self.lbl.text = str(int(args[1]))
def Dictation(self, *args):
self.lbl2.text = str(int(args[1]))
def Listening(self, *args):
self.lbl3.text = str(int(args[1]))
def Speaking(self, *args):
self.lbl4.text = str(int(args[1]))
class ExporterScreen(Screen):
def btn3(self):
# This section loads and saves the information stored from the user input.
self.pickle_in = open('dict.pickle', 'rb') # opens and assigns the opened pickle file to variable.
self.dict = pickle.load(self.pickle_in) # imports the saved pickle file and assigns it to a variable.
self.pickle_in.close() # closes the pickle file for safety.
print(self.dict)
self.df = pandas.DataFrame(self.dict, index=['Level', 'Reading', 'Writing', 'Dictation', 'Speaking'])
self.df.to_excel("student_data.xlsx")
class WindowManager(ScreenManager):
pass
kv = Builder.load_file("my2.kv")
class MyMainApp(App):
def build(self):
return kv
if __name__ == "__main__":
MyMainApp().run()
.Кв часть:
WindowManager:
MainWindow:
Controller:
ExporterScreen:
<MainWindow>:
name: "main"
first_name: first
last_name: last
GridLayout
cols: 1
size: root.width, root.height
GridLayout:
cols: 2
Label:
text: "Student First Name: "
TextInput:
id: first
multiline: False
Label:
text: "Student Last Name: "
TextInput:
id: last
multiline: False
Button:
size_hint: 0.3, 0.2
text: "Submit"
on_press: root.btn()
FloatLayout:
Button:
font_size: 25
size_hint: 0.3, 0.2
text: ">"
on_release:
app.root.current = "second"
root.manager.transition.direction = "left"
pos_hint: {"right":1, "bottom": 1}
Button:
font_size: 25
size_hint: 0.3, 0.2
text: "<"
on_release:
app.root.current = "second"
root.manager.transition.direction = "right"
pos_hint: {"left":1, "bottom": 1}
<Controller>
name: "second"
lbl: my_label
lbl2: my_label2
lbl3: my_label3
lbl4: my_label4
first_last: first_last
first_last2: first_last2
level: level
BoxLayout:
orientation: 'vertical'
Label:
font_size: 25
text: 'Reading'
Label:
id: my_label
text: 'increase/decrease'
Slider:
min: 1
max: 100
on_value: root.Reading(*args)
Label:
font_size: 25
text: 'Dictation'
Label:
id: my_label2
text: 'increase/decrease'
Slider:
min: 1
max: 100
on_value: root.Dictation(*args)
Label:
font_size: 25
text: 'Writing'
Label:
id: my_label3
text: 'increase/decrease'
Slider:
min: 1
max: 100
on_value: root.Listening(*args)
Label:
font_size: 25
text: 'Speaking'
Label:
id: my_label4
text: 'increase/decrease'
Slider:
min: 1
max: 100
on_value: root.Speaking(*args)
Label:
text: "Level (Sky^, Sky, Earth, Rockets)"
TextInput:
multiline: False
id: level
GridLayout:
cols:2
Label:
text: "First Name"
TextInput:
font_size: 8
id: first_last
multiline: False
Label:
text: "Last Name"
TextInput:
font_size: 8
id: first_last2
multiline: False
GridLayout:
cols: 3
Button:
text: "<"
on_release:
app.root.current = "main"
root.manager.transition.direction = "right"
Button:
text: "Update"
on_press: root.btn2()
Button:
text: ">"
on_release:
app.root.current = "third"
root.manager.transition.direction = "left"
<ExporterScreen>
name: "third"
BoxLayout:
Button:
font_size: 25
size_hint: 0.3, 0.2
text: "Export Data"
on_press: root.btn3()