I'm new to Python.
By dragging and dropping an Excel file onto the app with wxPython, we are creating an app that will check if there are any mistakes in the calculation formula inside the file.
In addition, it is designed to notify you with a message box after the work is completed.
I created the same app in virtualbox so that it works on Windows 10, but it works normally although there are some differences such as file paths, so I had a problem with dealing with it.
We would appreciate it if you could help us.
When I drag and drop the Excel file, the following error occurs on the terminal.
Since it is not a completed version yet, check the output result to the terminal by inserting a code that serves as a mark in the middle like "print (" ------- ")" in the source code. I am coding while dragging and dropping, but only the following error message is output.
Corresponding source code
TypeError: invalid result from FileDropTarget.OnDropFiles (), a'bool' is expected not'NoneType' #FileDropTarget is the class name and OnDropFile () is the method name. * Described in the source code below.
import os import sys import wx import wx.adv import openpyxl as xl from openpyxl import Workbook, load_workbook import time sys.path.append (os.path.join (os.path.dirname (__ file__),'/ Users/username/~/virtual environment/lib/python3.9/site-packages')) ~~~~~ class FileDropTarget (wx.FileDropTarget): def __init __ (self, window): wx.FileDropTarget.__init__ (self) self.window = window def OnDropFiles (self, x, y, files): self.window.text_entry.SetLabel (files ) r_path = files  def Check (): print ("-------") ~~~~~ if VC () == True and WC () == True and XC () == True: print (True) wx.MessageBox (u "Thanks!", U "A") print ("-------") else: else: wx.MessageBox (u "Please review.", U "A") print ("Please review.") if __name__=='__main__': Check () class App (wx.Frame): def on_erase_background (self, event): dc = event.GetDC () if not dc: dc = wx.ClientDC (self) rect = self.GetUpdateRegion (). GetBox () dc.SetClippingRect (rect) dc.Clear () bmp = wx.Bitmap ("/Users/username/Desktop/bgi.png") dc.DrawBitmap (bmp) def __init __ (self, parent, id, title): wx.Frame.__init__ (self, parent, id, size = (300, 700), style = wx.DEFAULT_FRAME_STYLE) self.SetBackgroundStyle (wx.BG_STYLE_ERASE) self.frame = parent notebook = wx.Notebook (self, wx.ID_ANY) notebook.Bind (wx.EVT_ERASE_BACKGROUND, self.on_erase_background) panel = wx.Panel (notebook, wx.ID_ANY) notebook.InsertPage (0, panel,'Check') label1 = wx.StaticText (panel, wx.ID_ANY, style = wx.SIMPLE_BORDER) date_time = wx.DateTime.Now () label2 = wx.StaticText (panel, wx.ID_ANY, label = time.strftime (r'% Y /% m /% d'), style = wx.TE_RIGHT) self.timer = wx.Timer (self) self.timer.Start (1000) box = wx.StaticBox (panel, wx.ID_ANY,'ex') label1.SetDropTarget (FileDropTarget (self)) self.text_entry = wx.TextCtrl (panel, wx.ID_ANY) layout = wx.StaticBoxSizer (box, wx.VERTICAL) layout.Add (label1, flag = wx.EXPAND | wx.ALL, border = 10, proportion = 1) layout.Add (self.text_entry, flag = wx.EXPAND | wx.ALL, border = 10, proportion = 1) layout.Add (label2, flag = wx.EXPAND | wx.ALL, border = 10, proportion = 1) panel.SetSizer (layout) self.Show () app = wx.App () App (None, -1,'Title') app.MainLoop () def resource_path (relative): if hasattr (sys, "_MEIPASS"): return os.path.join (sys._MEIPASS, relative) return os.path.join (relative)
◆ Operating environment
・ PC: Macbook Air
・ OS: MacOS High Sierra
・ Language: Python 3.9
Answer # 1
As for the content of the error, where you expect a bool value
It's happening because None came.
The return value of the OnDropFiles method is bool, so
return TrueHow about trying it?
If there is no return, the Python function returns None.
- macos (osx) - ruby on rails installation error (`you don't have write permissions`)
- macos (osx) - i can't get up all the time with the error "visual studio code quit for an unexpected reason"
- macos (osx) - when i try to put gnuplot in homebrew, i get an error
- macos (osx) - error in homebrew update
- macos (osx) - error in rsync command in shell script
- macos (osx) - i want to fix bash_profile error (syntax error) in terminal
- macos (osx) - sort_valus method error macos
- macos (osx) - i get an error when i open the terminal
- macos (osx) - about fatal error displayed by git operation in terminal
- macos (osx) - jupyter lab chromedriver error
- macos (osx) - error with --time-style option of zsh ls command
- macos (osx) - talib install error
- macos (osx) - docker error
- macos (osx) - read_excel method file reading error macos
- macos (osx) - can't download "texi2html" file when doing brew install chromaprint with homebrew
- macos (osx) - about firebase cli installation
- macos (osx) - i want to make an application that displays a transparent operation window
- macos (osx) - question about webpacker error when building rails environment
- macos (osx) - virtual machine using virtualbox cannot be viewed in firefox
- python 3x - i want to run anaconda3 python from visual studio code it may or may not move
- macos (osx) - about image conversion using pdf2image, poppler
- python - how to format the indent into two
- how to enable c ++ opencv with vscode on mac
- i want to import readline only in mac environment with python
- i want to apply iterative processing to the whole sentence in python
- i want to make a console app like a calculator with python
- how to pass mac python path
- i counted the number of days elapsed with python