Skip to content

Instantly share code, notes, and snippets.

View driscollis's full-sized avatar

Mike Driscoll driscollis

View GitHub Profile
@driscollis
driscollis / event_props.py
Created November 5, 2018 17:00
Posting events across frames
import wx
class FrameOne(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title='Frame 1')
self.Bind(wx.EVT_CLOSE, self.on_close)
def on_close(self, event):
import wx
app = wx.App(False)
frame = wx.Frame(None, wx.ID_ANY, "Hello World")
icon = wx.Icon("py.ico")
frame.SetIcon(icon)
frame.Show()
app.MainLoop()
import os
import shutil
def copy_files_from_file(file_path):
with open(file_path) as f:
for line in f:
dirname, filename = os.path.dirname(line), os.path.basename(line)
proj_dir = os.path.join(dirname, 'ProjectData')
if os.path.exists(proj_dir):
shutil.move(match, os.path.join(proj_dir, filename))
import os
import shutil
def move_file_type_v2(path, ftype, excludes):
matches = glob.glob('{}/**/*{}'.format(path, ftype), recursive=True)
for match in matches:
dirname, filename = os.path.dirname(match), os.path.basename(match)
if dirname not in excludes:
proj_dir = os.path.join(dirname, 'ProjectData')
@driscollis
driscollis / generic_wxwizard.py
Created March 23, 2018 19:33
Accessing pages in a wizard
import wx
class WizardPage(wx.Panel):
""""""
def __init__(self, parent, title=None):
"""Constructor"""
wx.Panel.__init__(self, parent)
# eanbc_demo.py
from reportlab.graphics.barcode import eanbc
from reportlab.platypus import SimpleDocTemplate
from reportlab.platypus import Paragraph
from reportlab.lib.styles import getSampleStyleSheet
def eanbc_demo(barcode_value):
doc = SimpleDocTemplate('eanbc_demo.pdf')
@driscollis
driscollis / simple_toc.py
Created February 16, 2018 02:16
A simple table of contents using ReportLab (does not work!)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import SimpleDocTemplate, Paragraph
from reportlab.platypus import PageBreak
from reportlab.platypus.tableofcontents import TableOfContents
def simple_toc():
doc = SimpleDocTemplate("simple_toc.pdf")
story = []
styles = getSampleStyleSheet()
@driscollis
driscollis / demo_listbox.py
Last active January 18, 2018 22:49
Converting wxPython demo code to your code
import wx
#----------------------------------------------------------------------
# BEGIN Demo Code
class FindPrefixListBox(wx.ListBox):
def __init__(self, parent, id, pos=wx.DefaultPosition, size=wx.DefaultSize,
choices=[], style=0, validator=wx.DefaultValidator):
wx.ListBox.__init__(self, parent, id, pos, size, choices, style, validator)
self.typedText = ''
self.log = parent.log
@driscollis
driscollis / olv_move_items.py
Created November 16, 2017 14:47
An ObjectListView demo with moveable items
import wx
from ObjectListView import ObjectListView, ColumnDefn
class Book(object):
"""
Model of the Book object
Contains the following attributes:
'ISBN', 'Author', 'Manufacturer', 'Title'
@driscollis
driscollis / radios.py
Created November 3, 2017 14:43
7x24 grid of radio boxes
import wx
import wx.lib.scrolledpanel as scrolled
class MainPanel(scrolled.ScrolledPanel):
def __init__(self, parent):
scrolled.ScrolledPanel.__init__(self, parent)
main_sizer = wx.BoxSizer(wx.VERTICAL)