Skip to content

Commit

Permalink
Updated code for chapters 3, 9 and 13
Browse files Browse the repository at this point in the history
  • Loading branch information
driscollis committed Oct 6, 2017
1 parent ff0f8e5 commit 7912c23
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
Expand Up @@ -48,7 +48,7 @@ def updateControl(self, event):
"""
Update the object list view widget
"""
print "updating..."
print("updating...")
product_dict = [{"title":"Core Python Programming", "author":"Wesley Chun",
"isbn":"0132269937", "mfg":"Prentice Hall"},
{"title":"Python Programming for the Absolute Beginner",
Expand Down
10 changes: 3 additions & 7 deletions chapter_3_special_effects/recipe_3_2_dark_mode/dark_mode.py
@@ -1,10 +1,6 @@
# dark_mode.py
import wx

try:
from ObjectListView import ObjectListView
except:
ObjectListView = False
from ObjectListView import ObjectListView


def getWidgets(parent):
Expand All @@ -22,10 +18,10 @@ def getWidgets(parent):

def darkRowFormatter(listctrl, dark=False):
"""
Toggles the rows in a ListCtrl or ObjectListView widget.
Toggles the rows in a ListCtrl or ObjectListView widget.
"""

listItems = [listctrl.GetItem(i) for i
listItems = [listctrl.GetItem(i) for i
in range(listctrl.GetItemCount())]
for index, item in enumerate(listItems):
if dark:
Expand Down
Expand Up @@ -18,8 +18,8 @@ def OnDropFiles(self, x, y, filenames):
self.window.updateText("\n%d file(s) dropped at %d,%d:\n" %
(len(filenames), x, y))
for filepath in filenames:
self.window.updateText(filepath + '\n')
self.window.updateText(filepath + '\n')

return True


Expand All @@ -33,7 +33,7 @@ def __init__(self, parent):
file_drop_target = MyFileDropTarget(self)
lbl = wx.StaticText(self, label="Drag some files here:")
self.fileTextCtrl = wx.TextCtrl(self,
style=wx.TE_MULTILINE|wx.HSCROLL|wx.TE_READONLY)
style=wx.TE_MULTILINE|wx.HSCROLL)
self.fileTextCtrl.SetDropTarget(file_drop_target)

sizer = wx.BoxSizer(wx.VERTICAL)
Expand Down
@@ -1,4 +1,4 @@
import wx
import wx


class MyURLDropTarget(wx.PyDropTarget):
Expand Down Expand Up @@ -32,20 +32,20 @@ def __init__(self, parent):
font = wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False)

# create and setup first set of widgets
lbl = wx.StaticText(self,
lbl = wx.StaticText(self,
label="Drag some URLS from your browser here:")
lbl.SetFont(font)
self.dropText = wx.TextCtrl(
self, size=(200,200),
style=wx.TE_MULTILINE|wx.HSCROLL|wx.TE_READONLY)
self, size=(200,200),
style=wx.TE_MULTILINE|wx.HSCROLL)
dt = MyURLDropTarget(self.dropText)
self.dropText.SetDropTarget(dt)
firstSizer = self.addWidgetsToSizer([lbl, self.dropText])

# create and setup second set of widgets
lbl = wx.StaticText(self, label="Drag this URL to your browser:")
lbl.SetFont(font)
self.draggableURLText = wx.TextCtrl(self,
self.draggableURLText = wx.TextCtrl(self,
value="http://www.mousevspython.com")
self.draggableURLText.Bind(wx.EVT_MOTION, self.OnStartDrag)
secondSizer = self.addWidgetsToSizer([lbl, self.draggableURLText])
Expand Down Expand Up @@ -85,7 +85,7 @@ class DnDFrame(wx.Frame):

def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, parent=None,
wx.Frame.__init__(self, parent=None,
title="DnD URL Tutorial", size=(800,600))
panel = DnDPanel(self)
self.Show()
Expand Down
Expand Up @@ -25,11 +25,12 @@ def __init__(self, parent):

lbl = wx.StaticText(self, label="Drag some text here:")
self.myTextCtrl = wx.TextCtrl(
self, style=wx.TE_MULTILINE|wx.HSCROLL|wx.TE_READONLY)
self, style=wx.TE_MULTILINE|wx.HSCROLL)
text_dt = MyTextDropTarget(self.myTextCtrl)
self.myTextCtrl.SetDropTarget(text_dt)

sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(lbl)
sizer.Add(self.myTextCtrl, 1, wx.EXPAND)
self.SetSizer(sizer)

Expand Down

0 comments on commit 7912c23

Please sign in to comment.