I want to achieve

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.

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.
Corresponding source code
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 [0])
        r_path = files [0]
        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)
Supplementary information

◆ 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.