Skip to content

Instantly share code, notes, and snippets.

View driscollis's full-sized avatar

Mike Driscoll driscollis

View GitHub Profile
import PySimpleGUI as sg
import os.path
# --------------------------------- Define Layout ---------------------------------
# First the window layout...2 columns
left_col = [
[
sg.Text("Folder"),
@driscollis
driscollis / combo_changer.py
Created January 3, 2020 16:37
Changing a wx.CombBox contents dynamically
import wx
class MainPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
self.cb_value = 'One'
self.combo_contents = ['One', 'Two', 'Three']
@driscollis
driscollis / mvp_kivy_example.py
Created June 4, 2019 14:16
Kivy layout example
import kivy
import random
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
red = [1,0,0,1]
green = [0,1,0,1]
blue = [0,0,1,1]
import wx
from ObjectListView import ObjectListView, ColumnDefn
import time
class TimeObj:
def __init__(self, start, end):
self.start = time.strftime('%H:%M:%S',
time.gmtime(start))
self.end = time.strftime('%H:%M:%S',
import wx
class MyTree(wx.TreeCtrl):
def __init__(self, parent, id, pos, size, style):
wx.TreeCtrl.__init__(self, parent, id, pos, size, style)
class TreePanel(wx.Panel):
def __init__(self, parent):
@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)