glade filechooserdialog Where does the opened file go? - python-2.7

I learning how to use Python(2.7) GTK(2.0) and Glade(3.8) and at the moment i am trying to use the filechooserdialog to open a file and use it in my program, however i can not seem to find any information on where the opened file "goes". I have found many tutorials explaining how to use or make a file choosing dialog window but none explaning how to open the file in your program, for example i have a file with numbers that i want in a chart.
Does any of you kind gentlemen/women have a clue ?

Related

How to read file/write to a file in UWP C++

So does anyone know how to write/read files in UWP C++? "Normal" file streams that worked for me before in console apps like fstream doesn't work, I've been googling that for hours and I learned that UWP has no access for anything. I found this: https://learn.microsoft.com/en-us/windows/uwp/files/quickstart-reading-and-writing-files but it's C# and everything else in the internet is C# aswell.. can't copy with that, I got stuck.
My program is a simple password manager, what I want to do is implement 2 functions:
read 3 TextBoxes, get stuff from it and put it one line then add the line to a file
read whole file full of passwords and put it in a TextBlock
Help please

How to write log file so that it can be read with notepad in real time for C++

I need a logger for C++. And I found this post Small logger class, which led me to this simple logger http://www.drdobbs.com/cpp/201804215.
It mainly uses the following method to wirte to log file.
FILE* pFile = fopen("application.log", "a");
std::ostringstream os;
os<<"I am a log line."<<std::endl;
fprintf(pFile, "%s", os.str().c_str());
fflush(pFile);
But it doesn't work as I expected. I assume, with the log file open in notepad, each new log line would be showing immediately after fprintf and fflush. But it turned out that I have to close and reopen the file with notepad to see the update.
So is there a way to write log file in C++ that allows reading in real time, which makes the log file resemble win32 console or VS output window? I miss the days when I can dump everything to console.log in Javascript. :)
Thanks.
This is not a problem with your code, this is an issue with Notepad.
Notepad does not automatically check for changes in the file you have open.
Instead, you should use a tool that does, for instance Notepad++, or indeed most editors designed for programmers.
If you have installed cygwin, you could also use tail -f to monitor additions to the log file.
After the accepted answer from mjs pointed me in the right direction, I google searched "notepad auto refresh" and found this https://www.raymond.cc/blog/monitor-log-or-text-file-changes-in-real-time-with-notepad/.
It provides several options to monitor text file changes in Windows, including Notepad++ and other software specifically designed for monitoring text file changes, with features like keyword filter/highlight and save/load monitoring session.
You might find It interesting if you came across the same problem as mine. Cheers.

C++ - Making a program open itself

I have a program that opens a WAV file and then plots the waveform. If the WAV file has 2 channels, two graphs are shown, one for each channel. It's working fine but I want to add things in the File Menu that I created. So far, I have three buttons: New, Open File, and Close. So far, the Open File and the Close buttons are working fine.
I want to make the program to be able to let the user view several waveforms of several WAV Files at the same time. One option would be to create more graphs, the process would be quite tedious. Another option would be to open another window and this is what I want to do.
However, this is my problem. I made a quick search on how to open an existing program in C++, and so far, the solutions that I encounter involve opening an exe file and the project folder does not contain an exe file.
I also tried to take a quick look on the functions and I can't find the function that seems to open the window and I can't seem to find it.
Your best bet is to use fork. Alternatively you could use threads.
Use GetModuleFileName API to get the path+ name of your executable. Then Use ShellExecute to run this APP.

Show text from opened file

I am not sure how to explain this, so I will give a scenario.
I want to write a program, which will be set as the default program for a file extension. When the program opens, it will output everything in the program. i.e file.txt contains the word hello, and when opened, my program opens and displays the word hello.
The idea is like Notepad. When a text file is opened, the contents are displayed. However, mine will be in a DOS window.
How can I achieve this?
Sorry if there is another question like this somewhere on here, TBH I am not too sure what this is called and thus can't search.
EDIT: My apologies. I am running Windows 7
If you open a file "with" your program (for instance using file type associations or by dragging the file onto the .exe), then the filename of the data file is passed as the command-line parameter to your application.
See:
What are the arguments to main() for?
I want to write a program, which will be set as the default program for a file extension.
See:
How File Associations Work
File Types and File Associations
You will associate your app with file extension and your app will do whatever it has to do.

how do I get win32 file browser with SDL?

I want to create an editor in C++ using SDL & OpenGL and have decided to use the win32 api to access the window bar menus (for file, edit and so on) and it seems quite simple, but I don't know how to create a "file-> open" file browser/loader... I'm hoping it's quite simple but I'm finding it hard to look up any tutorials on google because of the phrasing...
I just want to have an "open" or "import" option in the file menu that will open a standard windows file browser... then grab the file location, place it into a string then pass it into a function that is activated by selection a file... (I hope that makes sense).
The method I'm using to create the win32 menus are from this post:
http://www.gamedev.net/topic/400677-sdl-with-a-win32-menu/
Half way down the page there is a comment by "caseyd"... that's how I learnt how to use it, so that is my current understanding of win32 menus in SDL... I wanted to post the code here, but I didn't know how to paste it here in codeblocks without reformatting every line.
I'm hoping this is quite simple... Thanks to anyone who can teach me how or just point me in the right direction.
Oh, and I'm not trying to convert this to other operating systems, I just like SDL.
Use GetOpenFileName(). Note that that function blocks until the user selects a file, so if you want to continue rendering etc. in the background, make sure to run it on a separate thread.