Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

When I try to build a C++ project I get the error message in the title line. I am trying to help my son move his development from a unix cluster to his laptop. He is running Windows XP Pro and has installed the Eclipse IDE for C/C++ Developers. The version is Helios Repease 20100617-1415. He also has installed cygwin 1.7.7. The problem is (I think) related to ticpp. The error message from the compiler is

make: ***target pattern contains no '%'. Stop.

When I click on the error message it takes me to the following section of subdir.mk

# Each subdirectory must supply rules for building sources it contributes
ticpp-read-only/ticpp.o: D:/FRODAN/frodaN_home/ticpp-read-only/ticpp.cpp
@echo 'Building file: $<'
@echo 'Invoking: Cygwin C++ Compiler'
g++ -IE:/cygwin/lib/gcc/i686-pc-cygwin/3.4.4/include -I"D:\FRODAN\frodaN_home\frodaN" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '

Can anyone tell me what this error message means and what I can do to resolve it? I have done most of my development in (many years of coding) with a simple text editor. Any projects developed under a GUI were in Visual Studio so I know very little about eclipse.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

In the book, wxPython in Action (page 65), the following code shows how to bind an event to a frame (self) and to a button. In the case of the frame event (wx.EVT_CLOSE), no source argument is specified because the event is being bound to the object refenced as "self". The source argument is specified for the button binding because it is invoked as self.Bind. In examples I have seen elsewhere, however, the button event is bound to the button as button.Bind(wx.EVT_BUTTON,self.OnEvent,button). I have a few questions:

1) is it better to bind the button event as "self.Bind(event,handler,button)"
2) or as "button.Bind(event,handler)"
3) or as I have seen elsewhere, "button.Bind(event,handler,button)

And if the preferred method is #3, is it necessary to include the source argument when the source is implied as the object for which Bind is being invoked?

def __init__(self, parent, id): 
    wx.Frame.__init__(self, parent, id, 'Frame With Button', 
            size=(300, 100)) 
    panel = wx.Panel(self, -1)                               
    button = wx.Button(panel, -1, "Close", pos=(130, 15), size=(40, 40)) 
    self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)   
    self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You could also download SQLiteSpy (free) from
http://www.softpedia.com/progDownload/SQLiteSpy-Download-107386.html

It's a nice,small, robust SQL implementation

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Rather than trying to determine what the program is supposed to do by reading the code, could you please do your homework and add a few comments to the code as well as a summary of what the program is supposed to do?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

No offense taken. I just wanted to correct a minor point.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Quick note - Notepad is the simple editor that comes with Windows. Textpad is a much more feature rich editor sold by Helios Software (www.textpad.com) and should not be maligned by mistaking it for Notepad.

I'm just sayin'

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

And furthermore...

Don't overbuild.

Build in test points (log files) so you can see what is happening in your program (I wrote many dozens of real-time scripts that had to run continuously. You want to be able to find out what the processes are doing without stopping them, or see what they were doing before they failed.

If you are writing programs such as those above, decouple the processes so that a failure of one does not cascade.

Occam's razor applies. The simplest solution (not the sexiest one) that satisfies the specs is the desirable one.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I suggest you get a copy of the following. It contains detailed algorithms and instructions on creating and solving Sudoku puzzles. It uses VB 2005 as a base language.

Programming Sudoku
Copyright © 2006 by Wei-Meng Lee

ISBN-13 (pbk): 978-1-59059-662-3
ISBN-10 (pbk): 1-59059-662-5

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

My favourite "working" language has to be Python, even though I am relatively new to it. I spent the last ten years before retirement writing glue code in vbScript - mostly pumping data, reformatting data, fetching and storing data, system maintenance and SQL maintenance. All of which would have been immensely easier had I used Python.

Having said that, my favourite geek language is APL. Awesome language but it is impossible to read code that you wrote more than a week ago.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Or are you referring to the real world ;-)

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Be willing to share what you have learned when asked by others. Some people think that by hoarding knowledge they make themselves more valuable. An employee who is willing to raise the skills of his fellow employees is the valuable one.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

After much searching and digging (and weeping and gnashing of teeth) I finally have the answer. The following code should illustrate how to create a simple, three-page notebook control with a handler that identifies which page has just been selected. As an aside, I have included the widget inspection tool so that pressing CTRL-ALT-I while the GUI has focus displays the inspector

import wx
import wx.lib.mixins.inspection

class Frame(wx.Frame):

    def __init__(self, *args, **kwargs):

        wx.Frame.__init__(self,*args,**kwargs)
        
        # Create a notebook with three pages. Each page has one button.
        # It is important to give each panel a name because this is the
        # value returned by the expression "tab.GetName()" in the event
        # handler.
        
        nb = wx.Notebook(self)
        nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,self.OnTabChanged)

        for page in ("page 1","page 2","page 3"):
            panel  = wx.Panel(nb,name=page)
            sizer  = wx.FlexGridSizer(cols=13)
            panel.SetSizer(sizer)
            button = wx.Button(panel,label="Button",size=(60,30))
            sizer.Add(button,0)
            nb.AddPage(panel,page)

        self.Show()
        
    def OnTabChanged(self,event):
    
        tab = event.EventObject.GetChildren()[event.Selection]
        print "you selected tab " + tab.GetName()
        
        # If you don't include the following line your display won't
        
        event.Skip()

class MyApp(wx.App, wx.lib.mixins.inspection.InspectionMixin):

    def OnInit(self):

        self.Init()                      # initialize the inspection tool
        frame = Frame(None)
        self.SetTopWindow(frame)

        return True

app = MyApp(redirect=False)
app.MainLoop()
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Finally found this little gem

http://wiki.wxpython.org/wxPython%20Platform%20Inconsistencies

To wit...

Symptoms: When switching pages in a wxNotebook control subclass in GTK, everything works fine. When running the same code in MS Windows, the rendering and visibility of widgets is erroneous.

Solution: You are probably catching EVT_NOTEBOOK_PAGE_CHANGED, but in your event handler you aren't passing the event along to the next handler in the chain. You must do so in order to make sure the notebook control stays in a consistent state.

Solution - add the following line of code to the handler

event.Skip()
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If I may rant (politely, of course) for a moment...

I have found, in a programming career spanning 32 years, that there are a number of people out there who are more interested in dazzling you with their intelligence and knowledge than they are in sharing it. Sometimes this is intentional and sometimes not. For example, I spent several hours looking for examples of the notebook control. I even checked the demo program included with wxPython. Instead of simple, straightforward examples I mostly found examples consisting of subclass after subclass and which imported custom modules containing dozens of lines of irrelevant code that did nothing but cloud the explanation. As I tried to explain it to my non-technical wife, if she was looking for an example of how to create a certain stitch pattern, it would be massive overkill to be presented with a 50 page explanation of how to create a complex quilt, even if the explanation contained (somewhere) a very small section showing how to do the stitch pattern in question. So my simple request is that when asked for an example of a particular control, please try to limit the complexity to illustrate only the control in question.

Or am I being unreasonable?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

OK. It was painful but I started with a simple notebook that worked - no event handlers, just bare bones, then started adding stuff until it broke. The offending line was

self.nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,self.OnPageChange)

for some reason, nothing displays in the notebook pages after this line is executed.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Supplemental question. If, after line 18 I add the line

button = wx.Button(panel,label="Button",size=(60,30))

why, when I run the code, does nothing (no button) show up on the page? Come to think of it, I am not even sure the panels are being displayed. I have a feeling that I am missing something fundamental but I don't know what. As an aside, research done years ago shows that for most office people, their number one goal is to not feel like an idiot while they are working. I am clearly not attaining my goal.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Can someone please fill in the missing line of code in OnPageChange? I have a notebook control and on a page change event, I want to retrieve the label of the tab that was just selected. GetLabel and GetLabelText both return ''

import wx
import wx.lib.mixins.inspection

class Frame(wx.Frame):

	def __init__(self,parent=None):

		wx.Frame.__init__(self, None, -1, "test notebook",size=(300,300))
		self.Bind(wx.EVT_CLOSE,self.OnExit,self)

		self.CreateStatusBar()

		self.nb = wx.Notebook(self)
		self.nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,self.OnPageChange)

		for page in ("page 1","page 2","page 3"):

			panel = wx.Panel(self.nb)
			self.nb.AddPage(panel,page)

	def OnPageChange(self,event):

		#current = event.EventObject.?
		self.SetStatusText("current page is ...")

	def OnExit(self,event):

		self.Destroy()

class MyApp(wx.App, wx.lib.mixins.inspection.InspectionMixin):

	def OnInit(self):

		self.Init()  # initialize the inspection tool
		frame = Frame(None)

		frame.Show()
		self.SetTopWindow(frame)

		return True

app = MyApp(redirect=False)
app.MainLoop()
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The following function will return true if the given file is <= numsecs old. Just convert 3 hours to seconds and pass as an argument.

import os
import time

def newFile(file,numsecs):
	if time.time() - os.path.getctime(file) <= numsecs:
		return True
	else:
		return False