本文整理汇总了Python中wx.FileDropTarget方法的典型用法代码示例。如果您正苦于以下问题:Python wx.FileDropTarget方法的具体用法?Python wx.FileDropTarget怎么用?Python wx.FileDropTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.FileDropTarget方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FileDropTarget [as 别名]
def __init__(self, *args, **kwargs):
wx.Panel.__init__(self, *args, **kwargs)
# This is used to determine if a file dialog is open or not.
self.prev_file_path = ''
# Textbox for input file
self.text_ctrl = wx.TextCtrl(self, wx.ID_ANY, '')
self.text_ctrl.Bind(wx.EVT_TEXT, self.on_text_input)
self.button = wx.Button(self, wx.ID_ANY, _('Browse'))
self.button.Bind(wx.EVT_BUTTON, self.on_button_click)
# Drag and drop
drop_target = FileDropTarget(self)
self.text_ctrl.SetDropTarget(drop_target)
top_sizer = wx.BoxSizer(wx.HORIZONTAL)
top_sizer.Add(self.text_ctrl, proportion=1)
top_sizer.Add(self.button)
self.SetSizer(top_sizer)
示例2: on_button_click
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FileDropTarget [as 别名]
def on_button_click(self, event):
file_path = self.text_ctrl.GetValue()
if self.should_open_file(file_path):
evt = InputFileAddedEvent(input_file=file_path)
wx.PostEvent(self, evt)
self.prev_file_path = file_path
self.update_button_label()
return
# file_path is invalid. Open a file dialog.
file_dialog = wx.FileDialog(self, _('Select a video file'))
if file_dialog.ShowModal() != wx.ID_OK:
return
file_path = file_dialog.GetPath()
self.text_ctrl.SetValue(file_path)
# Callback from wx.FileDropTarget.OnDropFiles
示例3: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FileDropTarget [as 别名]
def __init__(self, window):
wx.FileDropTarget.__init__(self)
self.window = window
示例4: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FileDropTarget [as 别名]
def __init__(self, window, callback):
wx.FileDropTarget.__init__(self)
self.window = window
self.callback = callback
示例5: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FileDropTarget [as 别名]
def __init__(self, parent):
wx.FileDropTarget.__init__(self)
self.parent = parent
示例6: OnDragOver
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FileDropTarget [as 别名]
def OnDragOver(self, x, y, defResult):
x0,y0 = self.parent.GetClientAreaOrigin()
screen_xy = self.parent.ClientToScreen( (x-x0,y-y0) )
ctrl = wx.FindWindowAtPoint( screen_xy )
print("DragOver", x0,y0, x-x0,y-y0, ctrl)
return wx.FileDropTarget.OnDragOver(self, x,y, defResult)