Yes.
In this program, https://github.com/ElliotGarbus/BackingTrackPlayer, I have included ffmpeg.exe into the bundle and then call it using subprocess. If you look at the spec files, https://github.com/ElliotGarbus/BackingTrackPlayer/tree/master/BackingTrackPlayerDist you can see ffmpeg was included into the “datas” section, and copied to the current working directory.
I expect you could do something similar and then from python copy the code to the desktop, or just do it with the pyinstaller code, by setting the destination to dir in the datas to the desktop path.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/ef945d7c-7b4f-4039-a9b7-f2c90490ecb6n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/617acb1c.1c69fb81.df53.01a8SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/617acb1c.1c69fb81.df53.01a8SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-Vj-XejaKWTNEwBtkUFJjC1quC%3Djz54t%3DuDvvF3Zgg%2Bmtw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/1A0ED0AE-465A-47A1-B924-AE51E4ED7FDC%40cox.net.
I’d encourage you to create a simple test case.
I typically create a one dir build, and on windows I use inno setup to create a windows installer.
If you are doing a one_file building in py installer, there are additional actions you need to take to access data files.
See: https://pyinstaller.readthedocs.io/en/stable/runtime-information.html#run-time-information
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-Vg4cPhmw9XH5%3DSE6ZSRvFDvBAb%2Bb1uEBPxRWecMbc-Hwg%40mail.gmail.com.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
import os
from pathlib import Path
from shutil import copyfile
kv= '''
<check>:
FloatLayout:
Label:
text: 'a:'
font_size: 20
size_hint: .1,.1
pos_hint: {'x':.3, 'y': .5}
TextInput:
id: 'a_ti'
hint_text:'enter text'
size_hint: .3,.1
pos_hint: {'x':.4, 'y': .5}
Label:
text: 'b:'
font_size: 20
size_hint: .1,.1
pos_hint: {'x':.3, 'y': .4}
TextInput:
id: 'b_ti'
hint_text:'enter text'
size_hint: .3,.1
pos_hint: {'x':.4, 'y': .4}
Button:
text: 'Proceed'
size_hint: .2,.1
pos_hint: {'x':.6, 'y': .2}
on_press:
root.copy_file_to_desktop()
check:
id: conn
'''
class check (BoxLayout):
def copy_file_to_desktop(self):
exe_path = Path(__file__).parent / 'sample.txt'
print(f'exe_path is:-{exe_path}')
filename= 'sample.txt'
dest_path = os.path.join(os.path.expanduser('~\Desktop'),filename)
print('started file copy...')
copyfile(exe_path, dest_path)
print('file copy completed...')
class test(App):
def build(self):
return Builder.load_string(kv)
#executing
test().run()
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/617ecf06.1c69fb81.bc1c4.352bSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
I expanded your example to add a button to update the file.
I open the file on the desktop and update the data. I parsed the file and updated the data. If you have flexibility in your file format I would encourage you to use JSON this could provide a more robust solution. The simple parsing I did in the example can fail in a number of cases, but is sufficient for demonstration.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
import os
from pathlib import Path
from shutil import copyfile
kv =
'''
<check>:
FloatLayout:
Label:
text: 'a:'
font_size: 20
size_hint: .1,.1
pos_hint: {'x':.3, 'y': .5}
TextInput:
id: a_ti # id values are identifiers not strings
hint_text:'enter text'
size_hint: .3,.1
pos_hint: {'x':.4, 'y': .5}
Label:
text: 'b:'
font_size: 20
size_hint: .1,.1
pos_hint: {'x':.3, 'y': .4}
TextInput:
id: b_ti
hint_text:'enter text'
size_hint: .3,.1
pos_hint: {'x':.4, 'y': .4}
BoxLayout:
pos_hint: {'x':.6, 'y': .2}
Button:
text: 'copy to DT'
size_hint: None, None
size: 100, 48
on_press:
root.copy_file_to_desktop()
Button:
text: 'Update File'
size_hint: None, None
size: 100, 48
on_release: root.update_file(a_ti.text, b_ti.text)
check:
id: conn
'''
class check(BoxLayout):
def copy_file_to_desktop(self):
exe_path = Path(__file__).parent / 'sample.txt'
print(f'exe_path is:-{exe_path}')
filename = 'sample.txt'
dest_path = os.path.join(os.path.expanduser('~\Desktop'), filename)
print('started file copy...')
copyfile(exe_path, dest_path)
print('file copy completed...')
def update_file(self, a, b):
dest_path = Path('~\Desktop').expanduser() / 'sample.txt'
if not dest_path.exists():
return
with open(dest_path) as f:
lines = f.readlines()
line_a = lines[0].split('=')
line_a[1] = f'= {a}'
line_b = lines[1].split('=')
line_b[1] = f'= {b}'
new_data = ''.join(line_a) + '\n' + ''.join(line_b)
with open(dest_path, 'w') as f:
f.write(new_data)
class TestApp(App):
def build(self):
return Builder.load_string(kv)
# executing
TestApp().run()
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-Vi09zXr20jU-CvK404h15E0GTUUUCa%2Bfb5HAief5ucozg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6187e6e3.1c69fb81.8353.ba18SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
The use of an application configuration file is described here: https://kivy.org/doc/stable/api-kivy.app.html?highlight=build_config#application-configuration
Here is how the config file works in BackingTrackPlayer.
In the file main.py:
The method build_config() is called prior to on_start(). Looking specifically at BackingtrackPlayer, as an example:
def build_config(self, config):
config.setdefaults('MIDI', {'input': 'None',
'channel': 'None'})
config.setdefaults('Track', {'song': 'None'})
config.setdefaults('Window', {'width': window_width,
'height': window_height,
'top': window_top,
'left': window_left})
config.setdefaults('Recent Tracks', {'tracks': ''})
I am using setdefaults() to create the initial values of the ini file. If the file does not exist, it will be initialized with the values provided here. See: https://kivy.org/doc/stable/api-kivy.config.html?highlight=setdefaults#kivy.config.ConfigParser.setdefaults
In the on_stop method, the key parameters for the app are collected from the app and written to the config file:
def on_stop(self):
p = self.root.ids.sm.get_screen('play_screen').track_path
# update config file
if p:
self.config.set('Track', 'song', p)
tracks = ','.join(self.recent_track_paths)
self.config.set('Recent Tracks', 'tracks', tracks)
self.config.write()
if self.mc.midi_in_port and self.mc.midi_channel is not None:
self.config.set('MIDI', 'input', self.mc.midi_in_port.name)
self.config.set('MIDI', 'channel', self.mc.midi_channel)
self.config.write()
# clean up old files
if p:
fn = Path(p)
suffix = fn.suffix
speed_dir = Path(self.user_data_dir) / 'speeds'
for f in speed_dir.glob('*'):
if f.stem[:-4] + suffix != fn.name:
f.unlink() # remove files not related to current track
The code in get_application_config returns the path to the .ini file. This is the full path to the .ini file. I have changed the path to put it where I want on Windows and MacOS.
def get_application_config(self, defaultpath='%(appdir)s/%(appname)s.ini'):
if platform == 'win' or platform == 'macosx': # mac will not write into app folder
s = self.user_data_dir + '/%(appname)s.ini' # puts ini in AppData on Windows
else:
s = defaultpath
return super().get_application_config(defaultpath=s)
I also save the position and size of the Window. This is described here:
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-VgSOUJBQmMjTzADM-ZSG9AykTr6uJvvejwCYzuYa1sETw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/61883270.1c69fb81.2131a.1f2fSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
from kivy.app import App
from kivy.lang import Builder
import os
kv='''
FloatLayout:
Label:
text: 'Value:'
size_hint: .2,.1
pos_hint: {'x': .2, 'y':.5}
TextInput:
id: ti
hint_text: 'Enter Text'
size_hint: .2,.1
pos_hint: {'x': .35, 'y':.5}
'''
class TestApp(App):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def build_config(self, config):
config.setdefaults('section1', {
'key1': 'value1',
'key2': '42',
'key3': self.root.ids.ti.text
})
def get_application_config(self):
s = os.path.join(os.path.expanduser('~\Desktop'), 'checkcopy.ini')
return super(TestApp, self).get_application_config(s)
def build(self):
return Builder.load_string(kv)
TestApp().run()
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/61883270.1c69fb81.2131a.1f2fSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
I have expanded your example. Let me know if this helps.
from kivy.app import App
from kivy.lang import Builder
import os
kv=
'''
FloatLayout:
BoxLayout:
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
size_hint_y: None
height: dp(48)
Label:
text: 'Value:'
TextInput:
id: ti
hint_text: 'Enter Text'
Button:
text: 'Set Config Value'
on_release: app.update_config(ti.text)
'''
class TestApp(App):
def __init__(self, **kwargs):
super().__init__
(**kwargs)
def build_config(self, config): # This sets defaults if config does not exist
config.setdefaults('section1', {
'key1': 'value1',
'key2': '42',
'key3': 'Initial Text' # Build config is called before the kv code is processed.
})
def get_application_config(self):
s = os.path.join(os.path.expanduser('~\Desktop'), 'checkcopy.ini')
return super(TestApp, self).get_application_config(s)
def build(self):
return Builder.load_string(kv)
def on_start(self):
text = self.config.get('section1','key3')
self.root.ids.ti.text = text # set value of textinput with data from config
def update_config(self, text):
self.config.set('section1', 'key3', text) # update the config
self.config.write() # write the config to the file
TestApp().run()
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-VgSTQ0DrseKHTxxp4x58J5_edCLSXizyjdy2Yp8%2B6nfXQ%40mail.gmail.com.
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/awm-CKkXRiI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/61895122.1c69fb81.71f20.89f8SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/awm-CKkXRiI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/61895122.1c69fb81.71f20.89f8SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
I have no idea. I have not used putty, or the libraries you’ve mentioned. I would not expect that an app would accept input when it is minimized.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CABDb-VjfG1JRvP6mHTk1vEXkQw6DUz9GYLqL53SxgaTSMGs6NA%40mail.gmail.com.