A
A
Alexey R2020-03-02 12:59:17
Python
Alexey R, 2020-03-02 12:59:17

How to call methods from GUI?

Good afternoon dear IT specialists. I beg you to help me with one problem. I'm trying to write a simple program, the
meaning of which is to filter two excel files and display errors encountered in these files. This is my second programming experience
, as I realized for myself that programming needs to be learned by solving specific problems.
To be honest, it is not easy for me, but the desire is there. I understand that you will be horrified by my g..code, and that a lot of things were done
wrong at all (although I stole QAbstractTableModel from github), but I ran into a huge problem. I understand that this is a fundamental ignorance of OOP,
but still I ask you for help. I wrote a simple logic using Pandas and most likely can be made simpler and with the least amount of RAM,
but I will improve it as I learn python. The program works and counts everything. But only I can use it. Edit paths to archives in the .py file, etc.
maybe not everyone. So I decided to make a GUI. And this is a huge problem. The interface is ready and even works a little. But I don't understand how to pass
the paths to Excel files to .py files (for example, ParseExcelOMS) and, most importantly, I don't understand at all how to run the ParseExcelOMS.py file so that it starts parsing the file.
As I understand it, I will have to create some kind of method (function) for this implementation. In general, I am completely confused and do not know what to read and where to move.

In the end, I want what I would have succeeded.
There is a 1.xls and 2.xls file. In the GUI, I select one file and click Filter (Button_Calculate_OMS). As a result, progressBar_OMS should be activated
, a DataFrame should be formed and the number of people received as a result of the filter will be displayed in Count_Sum_OMS. The same goes for the second file. Then
I simply compare them, and I can save the result in Excel or view it right away. If you run the files separately, then everything turns out.
But I don't understand how to call all this from the GUI.

If Excel files are so necessary, I will try to change them and upload them. In the original, I can’t because they contain personal data of users.
https://github.com/AlexeyRepkin77/DispFilter#dispfilter "

ParseExcelOMS.py file
https://pastebin.com/6EUMr31t
ParseExcelMIS.py file
https://pastebin.com/L6WXsnzC
ParseDublicate.py file
https://pastebin. com/Aje5vn9s Visual.py
file
https://pastebin.com/GQCV1GDf
General.py file
https://pastebin.com/ZeBDPdmm

GUI DispFilterGUI.py
https://pastebin.com/b1NxeMpv

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2020-03-02
@trapwalker

It seems to me that you have taken on many tasks at once and are trying to solve them at the same time.
A good solution would be like this:

  1. Check out the main business logic as a separate library.
  2. Make a CLI interface for your functionality. This will be a separate script. which, using argparse, parses the command line options, extracts the arguments from them, and runs the business logic. Perhaps this will be enough. especially if you can put a rarely changed configuration into a separate json or yaml file and bind your utility to the "Open with" context menu at the operating system level. The CLI utility is quite capable of doing all the necessary transformations, creating a new document and opening it with Excel or whatever is attached to xls.
  3. If you really need a GUI, then I would not advise you to make a native application with windows and buttons for your task. You can make a trivial flask web service with a single web form that allows you to upload an xls file from your computer and then download the cached result. You can also display conversion errors by laying them out in html.

The beauty of a web service is that the deployment of the solution will be in a controlled server environment, and not on the user's machine, where anything can go wrong.
The development and support of such a solution is much cheaper.
OK. Let's get more to the point.
  1. Separate the contents of all your modules with business logic (ParseExcelOMS.py, ParseExcelMIS.py, etc.) into separate functions, the input arguments of which will be file names.
  2. Import these modules in a GUI module, and there, after obtaining the file names, call the desired functions.

If it doesn't work, come back with specific questions. It's not clear what exactly you don't understand. It seems that your code is too complicated for the author to misunderstand the concept of functions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question