Search Results

Search found 49286 results on 1972 pages for 'self type'.

Page 10/1972 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Describe the Damas-Milner type inference in a way that a CS101 student can understand

    - by user128807
    Hindley-Milner is a type system that is the basis of the type systems of many well known functional programming languages. Damas-Milner is an algorithm that infers (deduces?) types in a Hindley-Milner type system. Wikipedia gives a description of the algorithm which, as far as I can tell, amounts to a single word: "unification." Is that all there is to it? If so, that means that the interesting part is the type system itself not the type inference system. If Damas-Milner is more than unification, I would like a description of Damas-Milner that includes a simple example and, ideally, some code. Also, this algorithm is often said to do type inference. Is it really an inference system? I thought it was only deducing the types. Related questions: What is Hindley Miller? Type inference to unification problem

    Read the article

  • python getelementbyid from string

    - by matthewgall
    Hey, I have the following program, that is trying to upload a file (or files) to an image upload site, however I am struggling to find out how to parse the returned HTML to grab the direct link (contained in a ). I have the code below: #!/usr/bin/python # -*- coding: utf-8 -*- import pycurl import urllib import urlparse import xml.dom.minidom import StringIO import sys import gtk import os import imghdr import locale import gettext try: import pynotify except: print "Please install pynotify." APP="Uploadir Uploader" DIR="locale" locale.setlocale(locale.LC_ALL, '') gettext.bindtextdomain(APP, DIR) gettext.textdomain(APP) _ = gettext.gettext ##STRINGS uploading = _("Uploading image to Uploadir.") oneimage = _("1 image has been successfully uploaded.") multimages = _("images have been successfully uploaded.") uploadfailed = _("Unable to upload to Uploadir.") class Uploadir: def __init__(self, args): self.images = [] self.urls = [] self.broadcasts = [] self.username="" self.password="" if len(args) == 1: return else: for file in args: if file == args[0] or file == "": continue if file.startswith("-u"): self.username = file.split("-u")[1] #print self.username continue if file.startswith("-p"): self.password = file.split("-p")[1] #print self.password continue self.type = imghdr.what(file) self.images.append(file) for file in self.images: self.upload(file) self.setClipBoard() self.broadcast(self.broadcasts) def broadcast(self, l): try: str = '\n'.join(l) n = pynotify.Notification(str) n.set_urgency(pynotify.URGENCY_LOW) n.show() except: for line in l: print line def upload(self, file): #Try to login cookie_file_name = "/tmp/uploadircookie" if ( self.username!="" and self.password!=""): print "Uploadir authentication in progress" l=pycurl.Curl() loginData = [ ("username",self.username),("password", self.password), ("login", "Login") ] l.setopt(l.URL, "http://uploadir.com/user/login") l.setopt(l.HTTPPOST, loginData) l.setopt(l.USERAGENT,"User-Agent: Uploadir (Python Image Uploader)") l.setopt(l.FOLLOWLOCATION,1) l.setopt(l.COOKIEFILE,cookie_file_name) l.setopt(l.COOKIEJAR,cookie_file_name) l.setopt(l.HEADER,1) loginDataReturnedBuffer = StringIO.StringIO() l.setopt( l.WRITEFUNCTION, loginDataReturnedBuffer.write ) if l.perform(): self.broadcasts.append("Login failed. Please check connection.") l.close() return loginDataReturned = loginDataReturnedBuffer.getvalue() l.close() #print loginDataReturned if loginDataReturned.find("<li>Your supplied username or password is invalid.</li>")!=-1: self.broadcasts.append("Uploadir authentication failed. Username/password invalid.") return else: self.broadcasts.append("Uploadir authentication successful.") #cookie = loginDataReturned.split("Set-Cookie: ")[1] #cookie = cookie.split(";",0) #print cookie c = pycurl.Curl() values = [ ("file", (c.FORM_FILE, file)) ] buf = StringIO.StringIO() c.setopt(c.URL, "http://uploadir.com/file/upload") c.setopt(c.HTTPPOST, values) c.setopt(c.COOKIEFILE, cookie_file_name) c.setopt(c.COOKIEJAR, cookie_file_name) c.setopt(c.WRITEFUNCTION, buf.write) if c.perform(): self.broadcasts.append(uploadfailed+" "+file+".") c.close() return self.result = buf.getvalue() #print self.result c.close() doc = urlparse.urlparse(self.result) self.urls.append(doc.getElementsByTagName("download")[0].childNodes[0].nodeValue) def setClipBoard(self): c = gtk.Clipboard() c.set_text('\n'.join(self.urls)) c.store() if len(self.urls) == 1: self.broadcasts.append(oneimage) elif len(self.urls) != 0: self.broadcasts.append(str(len(self.urls))+" "+multimages) if __name__ == '__main__': uploadir = Uploadir(sys.argv) Any help would be gratefully appreciated. Warm regards,

    Read the article

  • Custom field not showing in Custom Content Type

    - by BeraCim
    Hi all: I created a custom column in a custom content type in a Sharepoint Web manually (e.g. /MySite/MyWeb). I now want to programmatically copy this content type across to another web (e.g. /MySite/MyWeb2). However, upon looping through the custom content type in code, I could only find 2 fields: Content Type and Title (expected: Title and custom column). The custom column was missing. I'm very sure that the content type and field are added at the web level. The custom content type is inherited from Item. When I loop through the web's fields, I can see the custom column, and that was copied to the new web. It is only within the content type that the custom column is not showing up. Any ideas why this is happening? Thanks.

    Read the article

  • Scalable way of doing self join with many to many table

    - by johnathan
    I have a table structure like the following: user id name profile_stat id name profile_stat_value id name user_profile user_id profile_stat_id profile_stat_value_id My question is: How do I evaluate a query where I want to find all users with profile_stat_id and profile_stat_value_id for many stats? I've tried doing an inner self join, but that quickly gets crazy when searching for many stats. I've also tried doing a count on the actual user_profile table, and that's much better, but still slow. Is there some magic I'm missing? I have about 10 million rows in the user_profile table and want the query to take no longer than a few seconds. Is that possible?

    Read the article

  • Haskell type classes and type families (cont'd)

    - by Giuseppe Maggiore
    I need some help in figuring a compiler error which is really driving me nuts... I have the following type class: infixl 7 --> class Selectable a s b where type Res a s b :: * (-->) :: (CNum n) => (Reference s a) -> (n,(a->b),(a->b->a)) -> Res a s b which I instance twice. First time goes like a charm: instance Selectable a s b where type Res a s b = Reference s b (-->) (Reference get set) (_,read,write) = (Reference (\s -> let (v,s') = get s in (read v,s')) (\s -> \x -> let (v,s') = get s v' = write v x (_,s'') = set s' v' in (x,s''))) since the type checker infers (-->) :: Reference s a -> (n,a->b,a->b->a) -> Reference s b and this signature matches with the class signature for (--) since Res a s b = Reference s b Now I add a second instance and everything breaks: instance (Recursive a, Rec a ~ reca) => Selectable a s (Method reca b c) where type Res a s (Method reca b c) = b -> Reference s c (-->) (Reference get set) (_,read,write) = \(x :: b) -> from_constant( Constant(\(s :: s)-> let (v,s') = get s :: (a,s) m = read v ry = m x :: Reference (reca) c (y,v') = getter ry (cons v) :: (c,reca) v'' = elim v' (_,s'') = set s' v'' in (y,s''))) :: Reference s c the compiler complains that Couldn't match expected type `Res a s (Method reca b c)' against inferred type `b -> Reference s c' The lambda expression `\ (x :: b) -> ...' has one argument, which does not match its type In the expression: \ (x :: b) -> from_constant (Constant (\ (s :: s) -> let ... in ...)) :: Reference s c In the definition of `-->': --> (Reference get set) (_, read, write) = \ (x :: b) -> from_constant (Constant (\ (s :: s) -> ...)) :: Reference s c reading carefully the compiler is telling me that it has inferred the type of (--) thusly: (-->) :: Reference s a -> (n,a->(Method reca b c),a->(Method reca b c)->a) -> (b -> Reference s c) which is correct since Res a s (Method reca b c) = b -> Reference s c but why can't it match the two definitions? Sorry for not offering a more succint and standalone example, but in this case I cannot figure how to do it...

    Read the article

  • Self Modifying Code

    - by Betamoo
    I am recently thinking about writing self-modifying programs, I think it may be powerful and fun... So I am currently looking for a language that allow modifying program own code easily.. I read about C# and the ability to compile -and execute- code in runtime, but that is too hurting.. I am also thinking about assembly... it is easier there to change running code but it is not very powerful... Can you suggest me a powerful language -or a feature- that support modifying code in runtime..? Hint: That what I mean by modifying code in runtime Start: a=10,b=20,c=0 label1: c=a+b .... label1= c=a*b goto label1 Thanks

    Read the article

  • SQL Server 2008 Delete Records from Self-Referencing Table in correct order

    - by KTrace
    I need to delete a sub set of records from a self-referencing table in SQL Server 2008. I am trying to do the following but it is does not like the order by. WITH SelfReferencingTable (ID, depth) AS ( SELECT id, 0 as [depth] FROM dbo.Table WHERE parentItemID IS NULL AND [t].ColumnA = '123' UNION ALL SELECT [t].ID, [srt].[depth] + 1 FROM dbo.Table t INNER JOIN SelfReferencingTable srt ON [t].parentItemID = [srt].id WHERE [t].ColumnA = '123' ) DELETE y FROM dbo.Table y JOIN SelfReferencingTable x on x.ID = y.id ORDER BY x.depth DESC Any ideas why this isn't working?

    Read the article

  • rails: self-referential association

    - by john
    hi, My needs are very simple: I have a Tip table to receive comments and have comments to receive comments, too. To retrieve each comment that is stored in the same table (comments), I created another key for the comments on comments: "inverse_comments". I tried to use one comments table by using self-referntial association. Some resources seem to bring more than one table into the piture which are diffent from my needs. So I came up whth the following modeling for comments: class Comment < ActiveRecord::Base belongs_to :tip belongs_to :user has_many :mycomments, :through => :inverse_comments, :source => :comment end Apparently something is missing here but I cannot figure it out. Could some one enlighten me on this: what changes I need to do to make the model work? thanks.

    Read the article

  • Using two joysticks in Cocos2D

    - by Blade
    Here is what I am trying to do: With the left joystick the player can steer the figure and with the right joystick it can attack. Problem is that the left joystick seems to get all the input, the right one does not even register anything. I enabled multipletouch after the eagleView and gone thoroughly over the code. But I seem to miss something. I initiliaze both sticks and it shows me both of them in game, but like I said, only the left one works. I initialize them both. From the h. file: SneakyJoystick *joystick; SneakyJoystick *joystickRight; And in m.file I synthesize, deallocate and initialize them. In order to use one for controlling and the other for attacking I put this: -(void)updateStateWithDeltaTime:(ccTime)deltaTime andListOfGameObjects:(CCArray*)listOfGameObjects { if ((self.characterState == kStateIdle) || (self.characterState == kStateWalkingBack) || (self.characterState == kStateWalkingLeft) || (self.characterState == kStateWalkingRight)|| (self.characterState == kStateWalkingFront) || (self.characterState == kStateAttackingFront) || (self.characterState == kStateAttackingBack)|| (self.characterState == kStateAttackingRight)|| (self.characterState == kStateAttackingLeft)) { if (joystick.degrees > 60 && joystick.degrees < 120) { if (self.characterState != kStateWalkingBack) [self changeState:kStateWalkingBack]; }else if (joystick.degrees > 1 && joystick.degrees < 59) { if (self.characterState != kStateWalkingRight) [self changeState:kStateWalkingRight]; } else if (joystick.degrees > 211 && joystick.degrees < 300) { if (self.characterState != kStateWalkingFront) [self changeState:kStateWalkingFront]; } else if (joystick.degrees > 301 && joystick.degrees < 360){ if (self.characterState != kStateWalkingRight) [self changeState:kStateWalkingRight]; } else if (joystick.degrees > 121 && joystick.degrees < 210) { if (self.characterState != kStateWalkingLeft) [self changeState:kStateWalkingLeft]; } if (joystickRight.degrees > 60 && joystickRight.degrees < 120) { if (self.characterState != kStateAttackingBack) [self changeState:kStateAttackingBack]; }else if (joystickRight.degrees > 1 && joystickRight.degrees < 59) { if (self.characterState != kStateAttackingRight) [self changeState:kStateAttackingRight]; } else if (joystickRight.degrees > 211 && joystickRight.degrees < 300) { if (self.characterState != kStateAttackingFront) [self changeState:kStateAttackingFront]; } else if (joystickRight.degrees > 301 && joystickRight.degrees < 360){ if (self.characterState != kStateAttackingRight) [self changeState:kStateAttackingRight]; } else if (joystickRight.degrees > 121 && joystickRight.degrees < 210) { if (self.characterState != kStateAttackingLeft) [self changeState:kStateAttackingLeft]; } [self applyJoystick:joystick forTimeDelta:deltaTime]; [self applyJoystick:joystickRight forTimeDelta:deltaTime]; } Maybe it has something to do with putting them both to time delta? I tried working around it, but it did not work. So I am thankful for any input you guys can give me :)

    Read the article

  • Plan your SharePoint 2010 Content Type Hub carefully

    - by Wayne
    Currently setting up a new environment on SharePoint 2010 (which was made available for download yesterday if anyone missed that :-). One of the new features of SharePoint 2010 is to set up a Content Type Hub (which is a part of the Metadata Service Application), which is a hub for all Content Types that other Site Collections can subscribe to. That is you only need to manage your content types in one location. Setting up the Content Type Hub is not that difficult but you must make it very careful to avoid a lot of work and troubleshooting. Here is a short tutorial with a few tips and tricks to make it easy for you to get started. Determine location of Content Type Hub First of all you need to decide in which Site Collection to place your Content Type Hub; in the root site collection or a specific one. I think using a specific Site Collection that only acts as a Content Type Hub is the best way, there are no best practice as of now. So I create a new Site Collection, at for instance http://server/sites/CTH/. The top-level site of this site collection should be for instance a Team Site. You cannot use Blank Site by default, which would have been the best option IMHO, since that site does not have the Taxonomy feature stapled upon it (check the TaxonomyFeatureStapler feature for which site templates that can be used). Configure Managed Metadata Service Application Next you need to create your Managed Metadata Service Application or configure the existing one, Central Administration > Application Management > Manage Service Applications. Select the Managed Metadata service application and click Properties if you already have created it. In the bottom of the dialog window when you are creating the service application or when you are editing the properties is a section to fill in the Content Type Hub. In this text box fill in the URL of the Content Type Hub. It is essential that you have decided where your Content Type Hub will reside, since once this is set you cannot change it. The only way to change it is to rebuild the whole managed metadata service application! Also make sure that you enter the URL correctly. I did copy and paste the URL once and got the /default.aspx in the URL which funked the whole service up. Make sure that you only use the URL to the Site Collection of the hub. Now you have to set up so that other Site Collections can consume the content types from the hub. This is done by selecting the connection for the managed metadata service application and clicking properties. A new dialog window opens and there you need to click the Consumes content types from the Content Type Gallery at nnnn. Now you are free to syndicate your Content Types from the Hub. Publish Content Types To publish a Content Type from the hub you need to go to Site Settings > Content Types and select the content type that you would like to publish. Then select Manage publishing for this content type. This takes you to a page from where you can Publish, Unpublish or Republish the content type. Once the content type is published it can take up to an hour for the subscribing Site Collections to get it. This is controlled by the Content Type Subscriber job that is scheduled to run once an hour. To speed up your publishing just go to Central Administration > Monitoring > Review Job Definitions > Content Type Subscriber and click Run now and you content type is very soon available for use. Published Content Type status You can check the status of the content type publishing in your destination site collections by selecting Site Settings > Content Type Publishing. From here you can force a refresh of all subscribed content types, see which ones that are subscribed and finally check the publishing error log. This error log is very useful for detecting errors during the publishing. For instance if you use any features such as ratings, metadata, document ids in your content type hub and your destination site collection does not have those features available this will be reported here.

    Read the article

  • When is the best time to do self learning in relation with software management?

    - by shankbond
    It all started from here. I have been following Software Estimation: Demystifying the Black Art (Best Practices (Microsoft)). The third chapter says that in Software Management: You cannot give too much time to software developers, if you give it to them, then it is likely that extra time given to them will be filled by some other tasks (in other words, the developers will eat that time :)) Parkinson's Law You can also not squeeze the time from their schedule because if you do that, it is likely that they will develop poor quality product, poor design and will hurt you in the long run, there will be a panic situation and total chaos in the project, lots of rework etc. My question is related to the first point. If you don't give enough time then will the typical software engineer learn his/her skills? The market is always coming with new technologies, you need to learn them. Even with the existing familiar technologies there are always best practices and dos and don'ts.

    Read the article

  • How important is self-teaching in the programming field? [closed]

    - by ThePlan
    I'm 16. I started programming about a year ago when I was about to start high-school. I'm going for a career in programming, and I'm doing my best to learn as much as I can. When I first started, I learned the basics of C++ from a book and I started to learn things by myself from there on. Nowadays I'm much more experienced than I was a year ago. I knew I had to study by myself because high-school won't (likely) teach me anything valuable about programming, and I want to be prepared. The question here is: how important is it to study programming by oneself?

    Read the article

  • "Learning" Linux

    - by Strider
    I've been interested in computers for a long time and have fiddled with a lot of stuff which includes Linux. I started out with Red Hat when I was young (around 13) and lost all data, converting a FAT32 drive to something else. Later it was Knoppix which was really helpful in recovery and such. Then, it was Ubuntu. Also, I fiddled with Arch for some time, but, it breaks too often for my liking (maybe, I should have been more careful). Anyway, currently I use Ubuntu 9.04. I want to dig deeper into the Linux world now. I want to learn how things work and use the terminal more. I am a programmer as well, so, it will help a lot. So, the thing I wanted to ask were: Good books to learn and understand Linux Good habits to use Linux more efficiently. Good tools about which I should know. Amount of time you set aside to learn about new things each day. As a programmer, how do you setup and use Linux efficiently. Long list. I will be grateful to the answerers.

    Read the article

  • Self hosted WCF ServiceHost/WebServiceHost Concurrency/Peformance Design Options (.NET 3.5)

    - by Kyle
    So I'll be providing a few functions via a self hosted (in a WindowsService) WebServiceHost (not sure how to process HTTP GET/POST with ServiceHost), one of which may be called a large amount of the time. This function will also rely on a connection in the appdomain (hosted by the WindowsService so it can stay alive over multiple requests). I have the following concerns and would be oh so thankful for any input/thoughts/comments: Concurrent access - how does the WebServiceHost handle a bunch of concurrent requests. Are they queued and processes sequentially or are new instances of the contracts automagically created? WebServiceHost - WindowsService communication - I need some form of communication from the WebServiceHost to the hosting WindowsService for things like requesting a new session if one does not exist. Perhaps implementing a class which extends the WebServiceHost with events which the WindowsService subscribes to... (unless there is another way I can set off an event in the WindowsService when a request is made...) Multiple WebServiceHosts or Contracts - Would it give any real performance gain to be running multiple WebServiceHost instances in different threads (one per endpoint perhaps?) - A better understanding of the first point would probably help here. WSDL - I'm not sure why (probably just need to do more reading), but I'm not sure how to get the WebServiceHost base endpoint to respond with a WDSL document describing the available contract. Not required as all the operations will be done via GET requests which will not likely change, but it would be nice to have... That's about it for the moment ;) I've been reading a lot on WCF and wish I'd gotten into it long ago, but definitely still learning.

    Read the article

  • Metaprogramming - self explanatory code - tutorials, articles, books

    - by elena
    Hello everybody, I am looking into improving my programming skils (actually I try to do my best to suck less each year, as our Jeff Atwood put it), so I was thinking into reading stuff about metaprogramming and self explanatory code. I am looking for something like an idiot's guide to this (free books for download, online resources). Also I want more than your average wiki page and also something language agnostic or preferably with Java examples. Do you know of such resources that will allow to efficiently put all of it into practice (I know experience has a lot to say in all of this but i kind of want to build experience avoiding the flow bad decisions - experience - good decisions)? EDIT: Something of the likes of this example from the Pragmatic Programmer: ...implement a mini-language to control a simple drawing package... The language consists of single-letter commands. Some commands are followed by a single number. For example, the following input would draw a rectangle: P 2 # select pen 2 D # pen down W 2 # draw west 2cm N 1 # then north 1 E 2 # then east 2 S 1 # then back south U # pen up Thank you!

    Read the article

  • SQLite self-join performance

    - by Derk
    What I essentially want, is to retreive all features and values of products which have a particular feature and value. For example: I want to know all available hard drive sizes of products that have an Intel processor. I have three tables: product_to_value (product_id, feature_id, value_id) features (id, value) // for example Processor family, Storage size, etc. values (id, value) // for example Intel, 60GB, etc The simplified query I have now: SELECT features.name, featurevalues.name, featurevalues.value FROM products, products as prod2, features, features as feat2, values, values as val2 WHERE products.feature = features.id AND products.value = values.id AND products.product = prod2.product AND prod2.feature_id = feat2.id AND prod2.value_id = val2.id AND features.id = ? AND feat2.id = ? All columns have an index. I am using SQLite. The problem is that it's very slow (70ms per query, without the self-join it's <1ms). Is there a smarter way to fetch data like this? Or is this too much to ask from SQLite? I personally think I am simply overlooking something, as I am quite new to SQLite.

    Read the article

  • wxPthon problems with Wrapping StaticText

    - by Scott B
    Hello. I am having an issue with wxPython. A simplified version of the code is posted below (white space, comments, etc removed to reduce size - but the general format to my program is kept roughly the same). When I run the script, the static text correctly wraps as it should, but the other items in the panel do not move down (they act as if the statictext is only one line and thus not everything is visible). If I manually resize the window/frame, even just a tiny amount, everything gets corrected and displays as it is should. I took screen shots to show this behavior, but I just created this account and thus don't have the required 10 reputation points to be allowed to post pictures. Why does it not display correctly to begin with? I've tried all sorts of combination's of GetParent().Refresh() or Update() and GetTopLevelParent().Update() or Refresh(). I've tried everything I can think of but cannot get it to display correctly without manually resizing the frame/window. Once re-sized, it works exactly as I want it to. Information: Windows XP Python 2.5.2 wxPython 2.8.11.0 (msw-unicode) Any suggestions? Thanks! Code: #! /usr/bin/python import wx class StaticWrapText(wx.PyControl): def __init__(self, parent, id=wx.ID_ANY, label='', pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.NO_BORDER, validator=wx.DefaultValidator, name='StaticWrapText'): wx.PyControl.__init__(self, parent, id, pos, size, style, validator, name) self.statictext = wx.StaticText(self, wx.ID_ANY, label, style=style) self.wraplabel = label #self.wrap() def wrap(self): self.Freeze() self.statictext.SetLabel(self.wraplabel) self.statictext.Wrap(self.GetSize().width) self.Thaw() def DoGetBestSize(self): self.wrap() #print self.statictext.GetSize() self.SetSize(self.statictext.GetSize()) return self.GetSize() class TestPanel(wx.Panel): def __init__(self, *args, **kwargs): # Init the base class wx.Panel.__init__(self, *args, **kwargs) self.createControls() def createControls(self): # --- Panel2 ------------------------------------------------------------- self.Panel2 = wx.Panel(self, -1) msg1 = 'Below is a List of Files to be Processed' staticBox = wx.StaticBox(self.Panel2, label=msg1) Panel2_box1_v1 = wx.StaticBoxSizer(staticBox, wx.VERTICAL) Panel2_box2_h1 = wx.BoxSizer(wx.HORIZONTAL) Panel2_box3_v1 = wx.BoxSizer(wx.VERTICAL) self.wxL_Inputs = wx.ListBox(self.Panel2, wx.ID_ANY, style=wx.LB_EXTENDED) sz = dict(size=(120,-1)) wxB_AddFile = wx.Button(self.Panel2, label='Add File', **sz) wxB_DeleteFile = wx.Button(self.Panel2, label='Delete Selected', **sz) wxB_ClearFiles = wx.Button(self.Panel2, label='Clear All', **sz) Panel2_box3_v1.Add(wxB_AddFile, 0, wx.TOP, 0) Panel2_box3_v1.Add(wxB_DeleteFile, 0, wx.TOP, 0) Panel2_box3_v1.Add(wxB_ClearFiles, 0, wx.TOP, 0) Panel2_box2_h1.Add(self.wxL_Inputs, 1, wx.ALL|wx.EXPAND, 2) Panel2_box2_h1.Add(Panel2_box3_v1, 0, wx.ALL|wx.EXPAND, 2) msg = 'This is a long line of text used to test the autowrapping ' msg += 'static text message. ' msg += 'This is a long line of text used to test the autowrapping ' msg += 'static text message. ' msg += 'This is a long line of text used to test the autowrapping ' msg += 'static text message. ' msg += 'This is a long line of text used to test the autowrapping ' msg += 'static text message. ' staticMsg = StaticWrapText(self.Panel2, label=msg) Panel2_box1_v1.Add(staticMsg, 0, wx.ALL|wx.EXPAND, 2) Panel2_box1_v1.Add(Panel2_box2_h1, 1, wx.ALL|wx.EXPAND, 0) self.Panel2.SetSizer(Panel2_box1_v1) # --- Combine Everything ------------------------------------------------- final_vbox = wx.BoxSizer(wx.VERTICAL) final_vbox.Add(self.Panel2, 1, wx.ALL|wx.EXPAND, 2) self.SetSizerAndFit(final_vbox) class TestFrame(wx.Frame): def __init__(self, *args, **kwargs): # Init the base class wx.Frame.__init__(self, *args, **kwargs) panel = TestPanel(self) self.SetClientSize(wx.Size(500,500)) self.Center() class wxFileCleanupApp(wx.App): def __init__(self, *args, **kwargs): # Init the base class wx.App.__init__(self, *args, **kwargs) def OnInit(self): # Create the frame, center it, and show it frame = TestFrame(None, title='Test Frame') frame.Show() return True if __name__ == '__main__': app = wxFileCleanupApp() app.MainLoop() EDIT: See my post below for a solution that works!

    Read the article

  • PyQt application architecture

    - by L. De Leo
    I'm trying to give a sound structure to a PyQt application that implements a card game. So far I have the following classes: Ui_Game: this describes the ui of course and is responsible of reacting to the events emitted by my CardWidget instances MainController: this is responsible for managing the whole application: setup and all the subsequent states of the application (like starting a new hand, displaying the notification of state changes on the ui or ending the game) GameEngine: this is a set of classes that implement the whole game logic Now, the way I concretely coded this in Python is the following: class CardWidget(QtGui.QLabel): def __init__(self, filename, *args, **kwargs): QtGui.QLabel.__init__(self, *args, **kwargs) self.setPixmap(QtGui.QPixmap(':/res/res/' + filename)) def mouseReleaseEvent(self, ev): self.emit(QtCore.SIGNAL('card_clicked'), self) class Ui_Game(QtGui.QWidget): def __init__(self, window, *args, **kwargs): QtGui.QWidget.__init__(self, *args, **kwargs) self.setupUi(window) self.controller = None def place_card(self, card): cards_on_table = self.played_cards.count() + 1 print cards_on_table if cards_on_table <= 2: self.played_cards.addWidget(card) if cards_on_table == 2: self.controller.play_hand() class MainController(object): def __init__(self): self.app = QtGui.QApplication(sys.argv) self.window = QtGui.QMainWindow() self.ui = Ui_Game(self.window) self.ui.controller = self self.game_setup() Is there a better way other than injecting the controller into the Ui_Game class in the Ui_Game.controller? Or am I totally off-road?

    Read the article

  • Creating C# Type from full name

    - by Adi Barda
    I'm trying to get a Type object from type full name i'm doing the folowing: Assembly asm = Assembly.GetEntryAssembly(); string toNativeTypeName="any type full name"; Type t = asm.GetType(toNativeTypeName); I get null, why? the assembly is my executable (.net executable) and the type name is: System.Xml.XmlNode

    Read the article

  • Xuggler errors as soon as you import git

    - by user3241507
    I downloaded the Git straight into Eclipse for Xuggler (Here is the git). But as soon as it loads, there are so many errors I don't know what to do. Most of the errors are "cannot be resolved" type errors. Description Resource Path Location Type The import org.junit cannot be resolved AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 22 Java Problem The import junit cannot be resolved AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 28 Java Problem TestCase cannot be resolved to a type AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 30 Java Problem The import org.slf4j cannot be resolved AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 23 Java Problem The import org.slf4j cannot be resolved AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 24 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 94 Java Problem Test cannot be resolved to a type AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 97 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 102 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 103 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 86 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 89 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 90 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 93 Java Problem Test cannot be resolved to a type AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com /xuggle/ferry line 114 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 120 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 125 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 126 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 106 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 107 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 110 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 111 Java Problem The method assertTrue(String, boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 53 Java Problem The method assertTrue(String, boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 49 Java Problem Ignore cannot be resolved to a type AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 57 Java Problem Test cannot be resolved to a type AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 56 Java Problem Before cannot be resolved to a type AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 37 Java Problem LoggerFactory cannot be resolved AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 32 Java Problem Test cannot be resolved to a type AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 44 Java Problem The method getName() is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 40 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 81 Java Problem Test cannot be resolved to a type AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 75 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 85 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 82 Java Problem Test cannot be resolved to a type AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 64 Java Problem The method assertTrue(String, boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 61 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 72 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 69 Java Problem NameAwareTestClassRunner cannot be resolved BufferTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 44 Java Problem The method assertTrue(String, boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 167 Java Problem The method debug(String, int, String) in the type Logger is not applicable for the arguments (String, int) AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 166 Java Problem The method fail(String) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 163 Java Problem After cannot be resolved to a type BufferTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 47 Java Problem NameAwareTestClassRunner cannot be resolved to a type BufferTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 35 Java Problem The method debug(String, int, String) in the type Logger is not applicable for the arguments (String) AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 162 Java Problem Test cannot be resolved to a type AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 135 Java Problem Before cannot be resolved to a type BufferTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 41 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 131 Java Problem LoggerFactory cannot be resolved BufferTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 38 Java Problem The method assertTrue(boolean) is undefined for the type AtomicIntegerTest AtomicIntegerTest.java /xuggle-xuggler-main/test/src/com/xuggle/ferry line 130 Java Problem The import org.junit cannot be resolved AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 22 Java Problem The import org.slf4j cannot be resolved AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 23 Java Problem The import org.slf4j cannot be resolved AudioSamplesTest.java /xuggle-xuggler-main/test /src/com/xuggle/xuggler line 24 Java Problem The import junit cannot be resolved AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 31 Java Problem TestCase cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 33 Java Problem Logger cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 35 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 82 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 80 Java Problem Logger cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 89 Java Problem Logger cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 84 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 94 Java Problem Logger cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 93 Java Problem Test cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 99 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 96 Java Problem Before cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 37 Java Problem LoggerFactory cannot be resolved AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 35 Java Problem The method getName() is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 40 Java Problem Logger cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 40 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 60 Java Problem Test cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 43 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 67 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 62 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 157 Java Problem Test cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 161 Java Problem Logger cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 154 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 155 Java Problem The method assertEquals(int, long) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 172 Java Problem The method assertEquals(long, long) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 173 Java Problem The method assertNotNull(IAudioSamples) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 168 Java Problem The method assertTrue(boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 171 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 124 Java Problem The method assertNotNull(IAudioSamples) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 129 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 117 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 119 Java Problem Logger cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 145 Java Problem Logger cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 150 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 141 Java Problem The method assertTrue(String, boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 143 Java Problem The method assertTrue(boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 216 Java Problem The method assertEquals(IBuffer.Type, IBuffer.Type) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 212 Java Problem The method assertTrue(boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 208 Java Problem The method assertNotNull(IAudioSamples) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 204 Java Problem The method assertEquals(IBuffer.Type, IBuffer.Type) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 218 Java Problem The method assertEquals(int, long) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 187 Java Problem The method assertTrue(boolean) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 186 Java Problem The method assertNotNull(IAudioSamples) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 183 Java Problem Test cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 176 Java Problem Test cannot be resolved to a type AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 197 Java Problem The method assertEquals(long, long) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 192 Java Problem The method assertEquals(long, long) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 191 Java Problem The method assertEquals(long, long) is undefined for the type AudioSamplesTest AudioSamplesTest.java /xuggle-xuggler-main/test/src/com/xuggle/xuggler line 188 Java Problem For a school project, I would like to build a simple live video stream program (final year in high school) like skype, except not as complicated. Can anyone help me solve these errors? or Is there another platform I can use that would be better/easier?

    Read the article

  • Python list recursion type error

    - by Jacob J Callahan
    I can't seem to figure out why the following code is giving me a TypeError: 'type' object is not iterable pastebin: http://pastebin.com/VFZYY4v0 def genList(self): #recursively generates a sorted list of child node values numList = [] if self.leftChild != 'none': numList.extend(self.leftChild.genList()) #error numList.extend(list((self.Value,))) if self.rightChild != 'none': numList.extend(self.rightChild.genList()) #error return numList code that adds child nodes (works correctly) def addChild(self, child): #add a child node. working if child.Value < self.Value: if self.leftChild == 'none': self.leftChild = child child.parent = self else: self.leftChild.addChild(child) elif child.Value > self.Value: if self.rightChild == 'none': self.rightChild = child child.parent = self else: self.rightChild.addChild(child) Any help would be appreciated. Full interpreter session: >>> import BinTreeNode as BTN >>> node1 = BTN.BinaryTreeNode(5) >>> node2 = BTN.BinaryTreeNode(2) >>> node3 = BTN.BinaryTreeNode(12) >>> node3 = BTN.BinaryTreeNode(16) >>> node4 = BTN.BinaryTreeNode(4) >>> node5 = BTN.BinaryTreeNode(13) >>> node1.addChild(node2) >>> node1.addChild(node3) >>> node1.addChild(node4) >>> node1.addChild(node5) >>> node4.genList() <class 'list'> >>> node1.genList() Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "C:...\python\BinTreeNode.py", line 47, in genList numList.extend(self.leftChild.genList()) #error File "C:...\python\BinTreeNode.py", line 52, in genList TypeError: 'type' object is not iterable

    Read the article

  • WCF Self Host Service - Endpoints in C#

    - by Kyle
    My first few attempts at creating a self hosted service. Trying to make something up which will accept a query string and return some text but have have a few issues: All the documentation talks about endpoints being created automatically for each base address if they are not found in a config file. This doesn't seem to be the case for me, I get the "Service has zero application endpoints..." exception. Manually specifying a base endpoint as below seems to resolve this: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using System.ServiceModel.Description; namespace TestService { [ServiceContract] public interface IHelloWorldService { [OperationContract] string SayHello(string name); } public class HelloWorldService : IHelloWorldService { public string SayHello(string name) { return string.Format("Hello, {0}", name); } } class Program { static void Main(string[] args) { string baseaddr = "http://localhost:8080/HelloWorldService/"; Uri baseAddress = new Uri(baseaddr); // Create the ServiceHost. using (ServiceHost host = new ServiceHost(typeof(HelloWorldService), baseAddress)) { // Enable metadata publishing. ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; host.Description.Behaviors.Add(smb); host.AddServiceEndpoint(typeof(IHelloWorldService), new BasicHttpBinding(), baseaddr + "SayHello"); //for some reason a default endpoint does not get created here host.Open(); Console.WriteLine("The service is ready at {0}", baseAddress); Console.WriteLine("Press to stop the service."); Console.ReadLine(); // Close the ServiceHost. host.Close(); } } } } I still think I'm doing something wrong as I don't get the normal "This is a web service...etc..." page when I load up the url How would I go about setting this up to return the value of name in SayHello(string name) when requested thusly: localhost:8080/HelloWorldService/SayHello?name=kyle Do I have to create an endpoing for the SayHello contract as well? I'm trying to walk before running, but this just seems like crawling...Service has zero application endpoints...

    Read the article

  • Multiple Context menus in PyQt based on mouse location

    - by Nader
    I have a window with multiple tables using QTableWidget (PyQt). I created a popup menu using the right click mouse and it works fine. However, I need to create different popup menu based on which table the mouse is hovering over at the time the right mouse is clicked. How can I get the mouse to tell me which table it is hovering over? or, put in another way, how to implement a method so as to have a specific context menu based on mouse location? I am using Python and PyQt. My popup menu is developed similar to this code (PedroMorgan answer from Qt and context menu): class Foo( QtGui.QWidget ): def __init__(self): QtGui.QWidget.__init__(self, None) # Toolbar toolbar = QtGui.QToolBar() # Actions self.actionAdd = toolbar.addAction("New", self.on_action_add) self.actionEdit = toolbar.addAction("Edit", self.on_action_edit) self.actionDelete = toolbar.addAction("Delete", self.on_action_delete) # Tree self.tree = QtGui.QTreeView() self.tree.setContextMenuPolicy( Qt.CustomContextMenu ) self.connect(self.tree, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menu) # Popup Menu self.popMenu = QtGui.QMenu( self ) self.popMenu.addAction( self.actionEdit ) self.popMenu.addAction( self.actionDelete ) self.popMenu.addSeparator() self.popMenu.addAction( self.actionAdd ) def on_context_menu(self, point): self.popMenu.exec_( self.tree.mapToGlobal(point) )

    Read the article

  • [Tkinter/Python] Different line widths with canvas.create_line?

    - by Sam
    Does anyone have any idea why I get different line widths on the canvas in the following example? from Tkinter import * bigBoxSize = 150 class cFrame(Frame): def __init__(self, master, cwidth=450, cheight=450): Frame.__init__(self, master, relief=RAISED, height=550, width=600, bg = "grey") self.canvasWidth = cwidth self.canvasHeight = cheight self.canvas = Canvas(self, bg="white", width=cwidth, height=cheight, border =0) self.drawGridLines() self.canvas.pack(side=TOP, pady=20, padx=20) def drawGridLines(self, linewidth = 10): self.canvas.create_line(0, 0, self.canvasWidth, 0, width= linewidth ) self.canvas.create_line(0, 0, 0, self.canvasHeight, width= linewidth ) self.canvas.create_line(0, self.canvasHeight, self.canvasWidth + 2, self.canvasHeight, width= linewidth ) self.canvas.create_line(self.canvasWidth, self.canvasHeight, self.canvasWidth, 1, width= linewidth ) self.canvas.create_line(0, bigBoxSize, self.canvasWidth, bigBoxSize, width= linewidth ) self.canvas.create_line(0, bigBoxSize * 2, self.canvasWidth, bigBoxSize * 2, width= linewidth) root = Tk() C = cFrame(root) C.pack() root.mainloop() It's really frustrating me as I have no idea what's happening. If anyone can help me out then that'd be fantastic. Thanks!

    Read the article

  • Python: Why Does a Method Behave Differently with an Added Parameter?

    - by SteveStifler
    I have a method in a Pygame Sprite subclass, defined as such: def walk(self): """move across screen""" displacement = self.rect.move((self.move, 0)) if self.rect.left < self.area.left or self.rect.right > self.area.right: self.move = -self.move displacement = self.rect.move((self.move, 0)) self.rect = displacement I modified it, adding a parameter speed_x, and now the program is broken. def walk(self, speed_x): """move across screen""" displacement = self.rect.move((speed_x, 0)) if self.rect.left < self.area.left or self.rect.right > self.area.right: speed_x = -speed_x displacement = self.rect.move((speed_x, 0)) self.rect = displacement Before I called the method like this: def update(self): self.walk() Now I do: def update(self): self.walk(self.move) Why doesn't this work?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >