'Kivy exe file showing a blank grey canvas
I'm getting a grey window only. Earlier my application crashed due to window not found error. I used this thread. It fixed that error, now im left with a grey window.
My code (sorry its a bit messy)
from kivy.app import App
from kivy.core import text
from kivy.uix.widget import Widget
#from kivy.uix.boxlayout import BoxLayout
from kivy.core.window import Window
from kivy.metrics import dp
from kivy.uix.gridlayout import GridLayout
from utils import Main
from kivy.uix.scrollview import ScrollView
from kivy.uix.label import Label
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.popup import Popup
from kivy.factory import Factory
from unipath import Path
from datetime import datetime
from kivy.lang import Builder
'''
'''
my_label = ''
Window.clearcolor = (150/255,150/255,150/255,1)
class MainWG(Widget):
def __init__(self, **kwargs):
super().__init__(**kwargs)
#Window.clearcolor = (150/255,150/255,150/255,1)
def sttwav(self, filename):
self.ids.label_update.text = 'Processing the file.....\nPlease wait....'
print('Add started' + filename[0])
#pop()
p = Path(filename[0])
np = str(p.parent)
print(my_label)
dt = datetime.now()
d = dt.strftime(("%Y-%m-%d %H-%M"))
with open(np + '\output' + d+'.txt', 'w') as f:
f.write(my_label)
f.close
self.ids.label_update.text = 'Transcript saved at '+ np + '\output'+d+'.txt\nRestart to transcribe another file'
print('file created ')
def sttmp3(self, filename):
self.ids.label_update.text = 'Processing the file.....\nPlease wait....'
print('Add started' + filename[0])
global my_label
#pop()
p = Path(filename[0])
np = str(p.parent)
print(my_label)
dt = datetime.now()
d = dt.strftime(("%Y-%m-%d %H-%M"))
#self.ids.update_label.text = 'Some error occured'
with open(np + '\output' + d+'.txt', 'w') as f:
f.write(my_label)
f.close
print('file created ')
self.ids.label_update.text = 'Transcript saved at '+ np + '\output'+d+'.txt\nRestart to transcribe another file'
print(my_label)
#self.ids.update_label.text = 'Some error occured'
#make a pop up class then call it using factory/norml
class Gridlayout(GridLayout):
def selected(self, filename):
address = filename[0]
print(address + '0')
class Scroll(ScrollView):
pass
class MyPopup(Popup):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.ids.update_label.text = my_label
def pop():
Factory.MyPopup().open()
#self.ids.my_popup.ids.scr.ids.update_label.text = my_label
#self.app.ids.update_label.text = my_label
#print(my_label)
#self.ids.update_label.text = 'Some error occured'
class MainApp(App):
pass
if __name__ == '__main__':
MainApp().run()
Kivy code
Gridlayout:
<MainWG>:
Button:
text: 'Start (for mp3 files)'
size: (150, 100)
size_hint: None, None
#pos_hint: { "x" : 0 , "top" : 1 }
pos: ('850dp','400dp')
background_color: 0,1,0,1
on_press: root.sttmp3(app.root.ids.filechooser.selection)
Button:
text: 'Start (for wav files)'
size: (150, 100)
size_hint: None, None
pos: ('850dp','280dp')
background_color: 0,1,0,1
on_press: root.sttwav(app.root.ids.filechooser.selection)
Label:
text: 'Select file from file explorer in left'
pos: ('900dp','500dp')
#pos_hint: { "right" : 0.7 , "y" : 0.7 }
size_hint: None, None
Label:
id: label_update
text: 'Please wait....\nAfter clicking start button'
pos: ('870dp','200dp')
<Gridlayout>:
cols: 2
id: my_widget
FileChooserIconView:
id: filechooser
on_selection: my_widget.selected(filechooser.selection)
MainWG
I have used pyinstaller to make its exe file. If im placing Builder to use .kv file then its throwing an error. I think it is not using kivy file which is mainly i have used
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|