Conversation started Jun 16, 2011 at 17:34.
Jun 16, 2011 17:34
Model–view–controller (MVC) is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing and maintenance of each (separation of concerns). History MVC was first described in 1979 by Trygve Reenskaug, then working on Smalltalk at Xerox PARC. The original implementation is described in depth in the influential paper "Applications Programming in Smalltalk-80: How to use Model–View–Con...
ok... so the message bit is used to establish communication between different controllers?
how it works is
a function in the panel or controller sends a message with pub.sendMessage
another function receives this by subscribing to the message
the message you subscribe to is the part between the quotes "message"
I use the name of the module. name of the function, so I know where the message is coming from
the function that's subscribed to the message needs to be able to receive it
def functionname(self, message): <-- needs a secondary item to receive the data
I call this message, because the tutorials used it
so it's not like where we just import a 'lib' from within the app and use it... we have to establish lines of communication between them... that right?
@KronoS The idea with MVC is to have your GUI code separated from the program logic
so that's why we don't import it
honestly, once you've done it a couple of times you'll see its very easy
AH.... ok that makes sense... so do you mind if we go line by line over 'calc_time'?
Jun 16, 2011 17:39
@KronoS sure :)
@IvoFlipse I'm sure it will... just still trying to get a grasp...
if message.data['stop'] == 0:
pass
ok so line one... you define the function with parameter (self, message)... what are those for?
message.data is needed because message is an object/class instance
for example if I was doing a simple addition function I would do:
sum(first_num,second_num)
but in this case it would be sum(self,message)
why?
Jun 16, 2011 17:42
@KronoS self is a standard when working with classes
when you create an instance of TaskTrackerController and you call the function calculate_time within it
you want that function to have access to the instance it**self**
the message part is just to have that function receive something
ok I think I understand... but how do I pass variables then?
in this case if you pass it 2 numbers in the message
you would do first_num, second_num = message.data (assuming it was a list/tuple with the two values)
AH!!! Ok... so self is the ability for the function to use itself... and message is the data that it's recieving...
which is also why its often better to use a dictionary, because while it requires you to know the keys, it doesn't break your program if the order messes up
@KronoS bingo :)
ok so then the second line: ` if message.data['stop'] ==0:`
pass
means that if there's no data of 'stop' then don't do anything... right?
Jun 16, 2011 17:47
def calculate_time(self, message):
        self.data = {'name':self.name, 'start':self.start, 'stop':self.stop}
        pub.sendMessage("tasktrackerpanel.calculate_time", self.data)
that's the function that sends the message
so it sends a dictionary with the start, stop times and the name of the button
Darn I so want to mess with Kinect...
@IvoFlipse you can learn C# :)
so if the key ['stop'] dictionary in message.data equals 0 or is False, you tell it to pass
@IvoFlipse wait... that's not in the tasktrackercontroller....
that's in tasktrackerpanel @KronoS, in the ButtonClass there
Oh ok...
Jun 16, 2011 17:49
@KronoS Python should be able to interface it as well
@KronoS just to show you why it says message.data['stop']
@IvoFlipse so that is the data that going to be passed into other functions then....
@KronoS yes, to any function that subscribes to "tasktrackerpanel.calculate_time"
@IvoFlipse oh really?
Ok ok... I think I'm starting to get this....
ok so i undserstand now the print line... it would print out something like:
Jun 16, 2011 17:53
print(message.data['name'],' took ', round(message.data['stop'] - message.data['start']), ' seconds')
" taskname took 35 seconds"
the name of the button + took + the rounded difference between stop - start time + seconds
but how is the task name passed when it's not def in tasktrackerpanel?
oh NVM... stupid me didn't see it
message.data['name'] ==> task/button name
How does it know though what task name it is? when I press the button that's all givin to it?
just like then I press the button the start/stop times are passed?
Jun 16, 2011 17:55
@KronoS that's the beauty of ButtonClass :)
class ButtonClass(wx.Panel):
    def __init__(self, parent, name):
        wx.Panel.__init__(self, parent)
        self.name = name
        # Initialize the timers
        self.start = 0
        self.stop = 0
when you create an instance of the button, you pass it along its name, so the class knows who he is
way back I would have been trying to name the class instances after the button they represent, but the only goal that serves is help my mental model. Which is wrong
@IvoFlipse how is that wrong?
@KronoS because objects only have attributes, of which its name is one. So whether you call the data_gathering or have some_name.name = 'data_gathering'
there's no real difference
oh wait... I think I understand now... it's better to define everything within the class and not afterwards....
ok so in order for my stats functions to be properly working, I'm going to have to create a 'message' link for established communication between it and the GUI
Hmmmm... ok... I think that I'm starting to get a hang of this slightly... so I should probably start with creating buttons and boxes for inputs in the statspanel and then move onto formulating the statscontroller
@KronoS yes, though the link is now going to be between the controllers rather than the GUI + controller
perhaps even 'better' would be to store the results in the database, then when you go to the statistics page, it pulls the results from the database
hold on... just had an emer at my work... brb
Jun 16, 2011 18:36
ok I'm back @IvoFlipse
too bad, I was just about to leave for a while, my GF needs attention
that's all good... I think I'm good for a little while
just shoot off all your questions and I'll try to answer them as good as possible
ok... have fun with the GF
you should try to make another panel to display your results
Jun 16, 2011 18:37
results of the stats or results of the data collected?
both, because technically they should be the same
but the first is the easiest obviously
but you need to find out how to 'switch' panels
ok...
I'll see what I can do...
This blog post explains the basic idea
what you do is you have mainframe
create an instance of all panels you want to display
after you've added them, set all but 1 to .Hide()
then when you switch the Ribbon Panel tab or push a button, it will switch that panel to .Hide() and another to .Show()
have a look in my code base to see how I did it
 
Conversation ended Jun 16, 2011 at 18:39.