I want to code a GUI in python, which uses browser window for surfing in folders, and can select multiple files and save their directory address in a dataframe. it can surf multi times and each one can select multi files' addresses.
I found PyQt to be pretty easy to use for making GUIs in python.
You can make a button:
file_button = QPushButton("Browse for files")
Then define a function to run when you click the button:
def file_button_on_click():
files = QFileDialog.getOpenFileNames(...)
Then connect that function to your button:
file_button.clicked.connect(file_button_on_click)
Related
I'm working on an app that has several buttons (10+) on the home screen that take the user to different pages with different functions, like home screen on Android or iOS where apps are located. The problem is, if all the different functions accessed from the home screen were to be put into one file, it would end up being over 10,000 lines in a single .py, which I've read is not good practice and can slow down the process.
How would one make it so that when the user presses a button for a task on the home screen, it accesses the code from a different .py without opening up a new window?
Thanks for your help!
So I have a shortcut to a personal area network device when I right-click the icon the context menu comes up with an option "connect Using -> access point".
Context menu image
I want to be able to do this operation automatically. I know that a program like AutoHotkey could do this very easily but I will be doing this operation multiple times per minute and if it is possible to do this in a command prompt or using python it would make my life easier
I have found a relatively non invasive method using pywinauto its not ideal for my application but it still works so I thought I would share
from pywinauto import Desktop, Application
Application().start('explorer.exe "path"')
app = Application(backend="uia").connect(path="explorer.exe", title="name1")
app2 = Desktop(backend='win32') #for sub actions only
app.folderName.set_focus()
common_files = app.folderName.ItemsView.get_item('fileName')
common_files.right_click_input()
app.ContextMenu.actionName.click_input()
app2.PopupMenu.menu_item('subActionName').click_input() #for sub actions only
app.window(title="name1").close()
I've created a few python scripts that I have to run every once in a while, but now I constantly have to type or search the location to the script in order to execute it. I have been looking for simple software to create an app with buttons, but without success. I have also seen "python?" scripts with an interface where you can select options with arrow keys, but also for this I have not found how it is done. Is there anyone who knows how I can make one of these that I can open the interface and select the script I want to execute? It would really save me a lot of time.
You can Tkinter to create the GUI, and for each button create a function that runs your python script like this:
# Create the button
button1 = Button \
(root, text='Start script1!', command=lambda: script1())
def script1():
os.system('python ~/path/to/script1.py')
def script2():
os.system('python ~/path/to/script2.py')
I recommend using PyQt because that framework is the powerful tool for building GUI on python and for running scripts from python code as system processes you can use subprocess module. I think you know how to use Google to find tutorials =) And also you can check the official page with GUI FAQ here. Thank you!
I've beeing coding applications for years using C# and Delphi. And one of the greatest things of those languages, in my opinion, was how easy it was to code the interface - you could grab the buttons, make the rectangles and etc, all using the mouse, dragging the squares.
Now I'm interested in Kivy, using Python. Can I construct the desktop interface just like Delphi, using the mouse and making the layout easily, or is the interface made only through coding?
Thanks for the patience, guys.
If you want to use kivy I suggest that you learn Kv Language which is a simple language to design the UI for kivy.
.kv file example:
<MyWidget>:
label_widget: label_widget
Button:
text: 'Add Button'
on_press: root.add_widget(label_widget)
Button:
text: 'Remove Button'
on_press: root.remove_widget(label_widget)
Label:
id: label_widget
text: 'widget'
There is however a Kivy Designer which you can use to design the UI but it is still at alpha stage and not perfect yet.
WARNING: This project is at an unstable alpha stage and is not yet
suitable for general use. Contributions are welcome.
Kivy Designer is Kivy's tool for designing graphical user interfaces
(GUIs) from Kivy Widgets. You can compose and customize widgets, and
test them. It is completely written in Python using Kivy.
So if it doesn't do what you want, you can create a simple UI and have a look at the generated code so you get an idea of how the UI is written in python.
Currently I'm working with FileChooser a lot and I didn't find any mention of refreshing the widget in the docs. The widget is awesome, but if someone wants to refresh shown files, a movement from current directory is necessary to refresh files.
The problem is when you have a single directory as a rootpath and inside are only files, therefore no such movement is possible.
My question was how to refresh the widget if I want to avoid any wasteful removing/adding of FileChooser and do it as short as possible for a FileChooser that is very nested in a kv file.
After I searched filechooser.py I found the code which is triggered on each movement between directories. Giving the fact the FileChooserIconView and FileChooserListView inherit from FileChooserController, the access to the function is simple and no additional imports are required.
Let's say we have filechooser = FileChooserIconView():
filechooser._update_files() works well and when is FileChooser nested somewhere, it's easy to access it with id
For more tweaks Clock.schedule_interval(filechooser._update_files, t) may be helpful where you can update your directory content within a reasonable time.
(I add it here, because I found no mention of it, however it may be useful to someone.)