Python Forum
Cancelling 'open directory' leading to crash
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cancelling 'open directory' leading to crash
#1
Hi there,

So I'm pretty new to Python coding, I have old code here that isn't very robust when it comes to extreme user inputs. I'm trying to fix that.
The first button on my GUI loads in a file, and opens a directory to allow the user to select which file they want. When I click cancel or 'x' the directory, my program crashes.

I've had a search online and I'm not sure whether I'm not searching the right terminology, but I can't seem to find anything that fixes this. This should be fairly straightforward.
Could someone point me in the right direction?

I basically want a workaround that allows the program to take 'cancelling' or 'x'ing the directory as a reasonable input without crashing.

Thanks in advance.
Reply
#2
Find the dialog in your code that opens the find-file window
and put try/ except / finally around it.
Then you will know the excact reason.
Probably if you put "pass" in the except part, it may pass, but you will not know why.

Paul
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Coding error. Can't open directory EddieG 6 1,183 Jul-13-2023, 06:47 PM
Last Post: deanhystad
  Removing leading whitespaces palladium 1 746 Mar-24-2023, 04:15 PM
Last Post: bowlofred
  Removing leading\trailing spaces azizrasul 8 2,833 Oct-23-2022, 11:06 PM
Last Post: azizrasul
  How to retrieve records in a DataFrame (Python/Pandas) that contains leading or trail mmunozjr 3 1,812 Sep-05-2022, 11:56 AM
Last Post: Pedroski55
  -i option changes sys.path (removes leading empty string '') markanth 6 2,050 Aug-26-2022, 09:27 PM
Last Post: markanth
  Catching a crash within a library code ebolisa 9 3,267 Nov-22-2021, 11:02 AM
Last Post: bowlofred
  Cancelling previous schedule cosmarchy 2 2,871 Sep-15-2021, 04:55 PM
Last Post: Larz60+
  Python Crash Course ( 2nd edition) alok 1 1,932 Jul-19-2021, 05:55 PM
Last Post: snippsat
  How to keep leading zeros with pandas? eeps24 1 6,644 May-20-2020, 07:51 PM
Last Post: deanhystad
  Im using python crash course version 2 james_newbie 3 2,447 Sep-07-2019, 09:21 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020