Daily Archives

Articles indexed Saturday May 22 2010

Page 13/81 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Object-oriented GUI development in python

    - by ptabatt
    Hey guys, new programmer here. I have an assignment for class and I'm stuck... What I need to do is a create a GUI that gives someone a basic arithmetic problem in one box, asks the person to answer it, evaluates it, and tells you if you're right or wrong... Basically, what I have is this: [code] class Lesson(Frame): def init (self, parent=None): Frame.init(self, parent) self.pack() Lesson.make_widgets(self) def make_widgets(self): Label(self, text="").pack(side=TOP) ent = Entry(self) self.a = randrange(1,10) self.b = randrange(1,10) self.expr = choice(["+","-"]) ent.insert(END, str(self.a) + str(self.expr) + str(self.a)) [/code] I've broken this down into many little steps and basically, what I'm trying to do right now is insert a default random expression into the first entry widget. When I run this code, I just get a blank Label. Why is that? How can I put a something like "7+7" into the box? If you absolutely need background to the problem, it's question #3 on this link. http://reed.cs.depaul.edu/lperkovic/csc242/homeworks/Homework8.html -Thanks for all help in advance.

    Read the article

  • Square collision detection problem (iPhone).

    - by thyrgle
    Hi, I know I've probably posted three questions related to this then deleted them, but thats only because I solved them before I got an answer. But, this one I can not solve and I don't believe it is that hard compared to the others. So, with out further ado, here is my problem: So I am using Cocos2d and one of the major problem is they don't have buttons. To compensate for there lack in buttons I am trying to detect if when a touch ended did it collide with a square (the button). Here is my code: - (void)ccTouchesEnded:(NSSet*)touches withEvent:(UIEvent*)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:touch.view]; NSLog(@"%f", 240-location.y); if (isReady == YES) { if (((240-location.y) <= (240-StartButton.position.x - 100) || -(240-location.y) >= (240-StartButton.position.x) + 100) && ((160-location.x) <= (160-StartButton.position.y) - 25 || (160-location.x) >= (160-StartButton.position.y) + 25)) { NSLog(@"Coll:%f", 240-StartButton.position.x); CCScene *scene = [PlayScene node]; [[CCDirector sharedDirector] replaceScene:[CCZoomFlipAngularTransition transitionWithDuration:2.0f scene:scene orientation:kOrientationRightOver]]; } } } Do you know what I am doing wrong?

    Read the article

  • Is there a way to get direct_to_template to pass RequestContext in django?

    - by BigJason
    I have found myself writing the same view over and over. It is basically this: def home_index(request): return render_to_response('home/index.html', RequestContext(request)) To keep with the dry principal, I would like to utilize a generic view. I have seen direct_to_template, but it passes an empty context. So how can I use a generic view and still get the power of RequestContext?

    Read the article

  • Casting to derived type problem in C++

    - by GONeale
    Hey there everyone, I am quite new to C++, but have worked with C# for years, however it is not helping me here! :) My problem: I have an Actor class which Ball and Peg both derive from on an objective-c iphone game I am working on. As I am testing for collision, I wish to set an instance of Ball and Peg appropriately depending on the actual runtime type of actorA or actorB. My code that tests this as follows: // Actors that collided Actor *actorA = (Actor*) bodyA->GetUserData(); Actor *actorB = (Actor*) bodyB->GetUserData(); Ball* ball; Peg* peg; if (static_cast<Ball*> (actorA)) { // true ball = static_cast<Ball*> (actorA); } else if (static_cast<Ball*> (actorB)) { ball = static_cast<Ball*> (actorB); } if (static_cast<Peg*> (actorA)) { // also true?! peg = static_cast<Peg*> (actorA); } else if (static_cast<Peg*> (actorB)) { peg = static_cast<Peg*> (actorB); } if (peg != NULL) { [peg hitByBall]; } Once ball and peg are set, I then proceed to run the hitByBall method (objective c). Where my problem really lies is in the casting procedurel Ball casts fine from actorA; the first if (static_cast<>) statement steps in and sets the ball pointer appropriately. The second step is to assign the appropriate type to peg. I know peg should be a Peg type and I previously know it will be actorB, however at runtime, detecting the types, I was surprised to find actually the third if (static_cast<>) statement stepped in and set this, this if statement was to check if actorA was a Peg, which we already know actorA is a Ball! Why would it have stepped here and not in the fourth if statement? The only thing I can assume is how casting works differently from c# and that is it finds that actorA which is actually of type Ball derives from Actor and then it found when static_cast<Peg*> (actorA) is performed it found Peg derives from Actor too, so this is a valid test? This could all come down to how I have misunderstood the use of static_cast. How can I achieve what I need? :) I'm really uneasy about what feels to me like a long winded brute-casting attempt here with a ton of ridiculous if statements. I'm sure there is a more elegant way to achieve a simple cast to Peg and cast to Ball dependent on actual type held in actorA and actorB. Hope someone out there can help! :) Thanks a lot.

    Read the article

  • Python scope problems only when _assigning_ to a variable

    - by wallacoloo
    So I'm having a very strange error right now. I found where it happens, and here's the simplest code that can reproduce it. def parse_ops(str_in): c_type = "operator" def c_dat_check_type(t): print c_type #c_type = t c_dat_check_type("number") >>> parse_ops("12+a*2.5") If you run it as-is, it prints "operator". But if you uncomment that line, it gives an error: Traceback (most recent call last): File "<pyshell#212>", line 1, in <module> parse_ops("12+a*2.5") File "<pyshell#211>", line 7, in parse_ops c_dat_check_type("number") File "<pyshell#211>", line 4, in c_dat_check_type print c_type UnboundLocalError: local variable 'c_type' referenced before assignment Notice the error occurs on the line that worked just fine before. Any ideas what causes this and how I can fix this? I'm using Python 2.6.1.

    Read the article

  • difference fixed width strings and zero-terminated strings

    - by robUK
    Hello, gcc 4.4.4 c89 I got into a recent discussion about "fixed width strings" and "zero terminated strings". When I think about this. They seem to be the same thing. A string with a terminating null. i.e. char *name = "Joe bloggs"; Is a fixed width string that cannot be changed. And also has a terminating null. Also in the discussion I was told that strncpy should never been used on 'zero terminated strings'. Many thanks for any susgestions,

    Read the article

  • Help modifying QuartzDemo example application

    - by BittenApple
    Can anyone please, oh sweet pain, please take me out of my misery by writing a simple example on how the heck you pass a number (int value) which gets created in 1 .m file to another .m file. In the apple demo application called QuartzDemo, there is a file called QuartzImages.m This file has the following line of code: [CODE]CGPDFPageRef page = CGPDFDocumentGetPage(pdf, 1);[/CODE] Notice the (pdf, 1) in that line. This number should be replaced with an integer variable. Now, there is also a file called MainViewController.m. In that file, there is a method? called -(void)viewDidLoad In that method, I want to assign a number to the integer variable which would replace the damn "1" with whatever number I want. I have been pulling my hair trying to get this done, reading beginning iPhone 3 Development book, dev documentation and God knows what not, without results. Any help would be greatly appreciated... Sigh.

    Read the article

  • What is it like working as a computer programmer

    - by Luke101
    I have a day job as an IT system administrator, but I do a lot of c# asp.net programming on my spare time. I have always wondered what its like to be a real software developer. I have taken a look at big CMS systems like umbraco and Dotnetnuke and said to myself that these developers must have decades of programming experience. Just the design of these products are overwhelming let alone the actual code. I just would like your comments on what it is like being a programmer.

    Read the article

  • How to record sound from a microphone in VB6?

    - by Clay Nichols
    We've been recording sound for over a decade using what seems like a very clunky method using the Winmm.dll and the MCIsendString. I've read that this doesn't set the recording quality value correctly (not sure if that article was ever true or is still true). I was wondering if there is any better way to record sound.

    Read the article

  • How to add a new page in Lift framework

    - by portoalet
    How can I add a new page in the webapp directory in lift that can be accessed by users? Currently only the index.html can be accessed through http://localhost:8080/ or http://localhost:8080/index.html Say I add a static file newpage.html into webapp dir, then what can I do so users can access it through http://localhost:8080/newpage.html ?

    Read the article

  • SCSF for Visual Studio 2010

    - by Anthony Trudeau
    The Smart Client Software Factory (SCSF) for Visual Studio 2010 was uploaded tonight.  You can get it, the source code, and the documentation on the patterns & practices page. Note: Do not forget to "unblock" the documentation (CHM) file after you download it.  To unblock it right click the file, choose Properties, and click the Unblock button.

    Read the article

  • A Wonderful Comment From a Very Inflential Microsoft Technology Company's Owner

    - by TheSilverlightGroup
    The Silverlight Group has been so very busy taking on state-of-the-art Silverlight development with huge, Fortune 500 companies! We have a great pool of talent, & if any of you Silverlight &/or Blend/UI/UX people are interested in joining us, our toll-free number is 1-888-863-6989. I'd like to point out that Nubifer, Inc.'s CEO, Chad Collins, http://channel9.msdn.com/posts/sureshs/Nubifer-cloud-solution-on-Windows-Azure/ , called our company "The Flagship Company for Silverlight Development"...thank you, Chad, as I see you at the same level for Cloud Computing. -See the SilverLIGHT!

    Read the article

  • Windows PE network setup

    - by microchasm
    I'm walking through the following step-by-step guide for deploying Windows 7 via AIK: http://technet.microsoft.com/en-us/library/dd349348%28WS.10%29.aspx On step 4 (Capturing the Installation onto a Network Share), I run into a bit of a snag: attempting to connect to a network drive repeatedly fails. I'm using/deploying Dell Optiplex 380 64 bit machines, and the network cards seem to be really wonky. On the machine that I'm using to run AIK etc, the network driver wasn't found automatically. I had to manually go in and install the driver (which was found on the OEM installation media). I've since copied this to the USB key that I'm using for the Autounattend.xml so its handy. I think that because of this, the PE environment doesn't or can't instantiate the network device. Is there a way to install/configure the network device through the command prompt in PE? If not, I read about adding in the answer file path(s) to drivers, but if I did it this way, would I have to start the process all over again (i.e. create new Autounattend.xml with the PnPcustomizations path included, re-run the installation on the reference machine, install all the applications, re-make the PE iso, reboot into new PE iso)? Any shortcuts, direction, or advice would be appreciated. Thanks!

    Read the article

  • File property information (last write time and file size) in explorer out of date by hours over netw

    - by David L Morris
    An application is running on a windows XP prof machine picking up file from a network share from another windows machine. It detects that the file has been updated (by date and time or optionally file size) and reads it for any new data. Most of the time the last write time and file size, seems to be up to date. Occasionally, this information stops being updated, even though the file is growing (intermittently during the day) with appended content, so that the last write time and file size remain fixed at some arbitrary moment. This is visible in explorer, where it shows a fixed last write time on the reading machine. Just opening the file to edit it in notepad, immediately refreshes the file properties, and the other application picks up where it left of. The file location can't be changed, nor the location of the relevant applications. Any solutions to resolve this problem?

    Read the article

  • What's normal Taskbar behavior (windows)

    - by Erik
    I'm a fairly new user to windows, and Vista is my first version. I'm a bit confused about the taskbar -- either its behaving oddly or I'm just confused, or I've broken something. When I've got a lot of windows on screen, I thought that clicking on a window's taskbar icon would bring that window to the front. I thought it had been doing that in the past, but I'm not entirely sure. When I click it, it just flashes, a second click minimized, and a third click reopens and brings it to the front. Is this normal?

    Read the article

  • ASP.NET Dynamic Data Browser Compatibility

    - by Petras
    Could any experienced users of Dynamic Data comment on whether there are issues with it in: Internet Explorer 6 Safari Chrome Opera We are looking to use it on a public facing website and good old IE6 has many important users in government departments and large companies so it has to work there. The other browsers could also become an issue.

    Read the article

  • What is Logically and semantically correct, A-grade browsers compatible and W3C valid way to clear f

    - by metal-gear-solid
    What is Logically correct and W3C valid way to clear float? zoom:1 is not valid by W3C and IE8 don't have hash layout problem overflow:hidden and overflow:hidden were not made to do this,as the spec intended overflow to be used <div class="clear"/> is not semantically correct and i don't want to add extra markup. clearfix hack generates content that really hasn’t any semantic value. I've asked many questions and read many articles on this issue but haven't find best way.

    Read the article

  • Avoiding sorting in NSDictionary

    - by RVN
    I was using NSDictionary and i observed that the objects in the dictionary are sorted automatically with respect to the keys, so my question is how to avoid this sorting , any flag available to set it off, so i get the object in same order i entered. i know u may be thinking what difference it makes in dictionary since we retrieve the value with respect to key, but i am first getting allKeys from which i receive Array of keys , this order is what i need it to be in the order of how i entered just as in NSArray. give your comments if the question is not clear. Thanks

    Read the article

  • Pass a hidden jqGrid value when editing on ASP.Net MVC

    - by taylonr
    I have a jqGrid in an ASP.Net MVC. The grid is defined as: $("#list").jqGrid({ url: '<%= Url.Action("History", "Farrier", new { id = ViewData["horseId"]}) %>', editurl: '/Farrier/Add', datatype: 'json', mtype: 'GET', colNames: ['horseId', 'date', 'notes'], colModel: [ { name: 'horseId', index: 'horseId', width: 250, align: 'left', editable:false, editrules: {edithidden: true}, hidden: true }, { name: 'date', index: 'farrierDate', width: 250, align: 'left', editable:true }, { name: 'notes', index: 'farrierNotes', width: 100, align: 'left', editable: true } ], pager: jQuery('#pager'), rowNum: 5, rowList: [5, 10, 20, 50], sortname: 'farrierDate', sortorder: "DESC", viewrecords: true }); What I want to be able to do, add a row to the grid, where the horseId is either a) not displayed or b) greyed out. But is passed to the controller when saving. The way it's set up is this grid will only have 1 horse id at a time (it will exist on a horse's property page.) The only time I've gotten anything to work is when I made it editable, but then that opens it up for the user to modify the id, which isn't a good idea. So is there some way I can set this value before submitting the data? it does exist as a variable on this page, if that helps any (and I've checked that it isn't null). Thanks

    Read the article

  • UINavigationController from scratch?

    - by Moshe
    I have a view based app that works well. (In other words, I'm not going to start over with a Navigation-Based App template.) It's an immersive app of sorts and I'm trying to add a Table View that loads in a new view when a button is pressed. The loading the nib part works, but I can't seem to be able to add a navigation controller to the new view. I want to see a navigation bar on top with a done button and an edit button. Also, I want to the Table View entries to be empty. I added a new file like so: File-> New File -> UINavigationController subclass. I checked the UITableViewController Subclass and With XIB for user interface. All I see when the view is pulled up is a blank Table View. I am able to customize things in the view controller. What can I do to make the table show a navigation bar and be editable? I need some direction here please. EDIT: I'm working with the latest Public SDK. (XCode 3.2.2)

    Read the article

  • HTTP request hangs for for exactly 150 seconds, then gives incomplete response. How do I find out wh

    - by Nathan
    I am hosting a Wordpress blog, and having a strange problem. When I connect to the server (http://71.65.199.125/ at the time of this writing) it displays the Title correctly, and half of a download bar, indicating it has received some of the page, then it hangs for exactly 150 seconds (timed it twice), then it sends the rest of the page, but without the stylesheet. after that it hangs indefinitely, continuing to say "connecting..." without making any progress. If you have any clues as to what might be happening, or how I could print debug logs of PHP or something to see what it is looking for during that hang time that would probably help. recent changed I have made: switched wordpress themes, however I did see it work once with the new theme. moved the server to another building, with an identical ISP, and linksys router forwarding setup. I have also added a favicon.gif file to /var/www but without linking to it from any of the wordpress pages. I have also had a unanticipated power interruption. System info: Ubuntu debian 9.04 Apache2 PHP 5 Wordpress 2.9.2 Thank you

    Read the article

  • Mouse clicks suddenly stopped working in Ubuntu

    - by DisgruntledGoat
    This is a weird one. For some reason, last night my mouse partially stopped working. Movement is fine, but the mouse buttons don't work. Mainly it's the left button, but occasionally the right click and scroll-wheel fail too. Initially I thought it could be the mouse itself (the left button seemed to get a bit "soft" recently), but I tried another mouse and had the same issue. Both are USB wireless optical mice. The keyboard is working okay 95%, only problem is Alt+Tab doesn't seem to work. Both keys work fine independently. At the time it happened I was using Chrome, I dragged to scrollbar to scroll and when I released the mouse it was still holding scrollbar. I'm using Ubuntu 9.10, I upgraded weeks ago and everything was working fine so I don't think it's related to that. I also hadn't run any updates (I have now just in case something fixed it). But no luck. Any ideas?

    Read the article

  • Effective way of String spliting C#

    - by openidsujoy
    I have a completed string like this N:Pay in Cash++RGI:40++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD++PPC:Points++D:Y++E:Y++IFE:Y++AD:Y++IR:++MV:++CP:~ ~N:ERedemption++RGI:42++R:200++T:Purchase++IP:N++IS:N++PD:PC++UCP:598.80++UPP:0.00++TCP:598.80++TPP:0.00++QE:1++QS:1++CPC:USD++PPC:Points++D:Y++E:Y++IFE:Y++AD:Y++IR:++MV:++CP: this string is like this It's list of PO's(Payment Options) which are separated by ~~ this list may contains one or more PO contains only Key-Value Pairs which separated by : spaces are denoted by ++ I need to extract the values for Key "RGI" and "N". I can do it via for loop , I want a efficient way to do this. any help on this.

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >