Search Results

Search found 10804 results on 433 pages for 'attribute keys'.

Page 34/433 | < Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >

  • Python: Dynamic attribute name generation without exec() or eval()

    - by PyNewbie27
    Hi, I'm trying to dynamically create buttons at runtime with PyQT4.7 However, this being my first python program I'm not sure how to get the functionality I want. I would like to be able to substitute a text string for an attribute name: i.e. for each in xrange(4): myname = "tab1_button%s" % each #tab1_button0, tab1_button1, tab1_button2 #self.ui.tab1_button0 = QtGui.QPushButton(self.ui.tab) <--normal code to create a named button setattr(self.ui,myname,QtGui.QPushButton(self.ui.tab)) #rewrite of line above to dynamicly generate a button #here's where I get stuck. this code isn't valid, but it shows what i want to do self.ui.gridLayout.addWidget(self.ui.%s) % myname #I need to have %s be tab1_button1, tab1_button2, etc. I know the % is for string substituion but how can I substitute the dynamically generated attribute name into that statement? I assume there's a basica language construct I'm missing that allows this. Since it's my first program, please take it easy on me ;)

    Read the article

  • Python: Getting the attribute name that the created object will be given

    - by cool-RR
    Before I ask this, do note: I want this for debugging purposes. I know that this is going to be some bad black magic, but I want to use it just during debugging so I could identify my objects more easily. It's like this. I have some object from class A that creates a few B instances as attributes: class A(object): def __init__(self) self.vanilla_b = B() self.chocolate_b = B() class B(object): def __init__(self): # ... What I want is that in B.__init__, it will figure out the "vanilla_b" or whatever attribute name it was given, and then put that as the .name attribute to this specific B. Then in debugging when I see some B object floating around, I could know which one it is. Is there any way to do this?

    Read the article

  • Hibernate updating records and implementing listeners : getting only required attribute values for event.getOldState()

    - by Narendra
    Hi All, I am using Hibernate 3 as my persistence framework. Below is the sample hbm file I am using. <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.test.User" table="user"> <meta attribute="implements">com.test.dao.interfaces.IEntity</meta> <id name="key" type="long" column="user_key"> <generator class="increment" /> </id> <property name="userName" column="user_name" not-null="true" type="string" /> <property name="password" column="password" not-null="true" type="string" /> <property name="firstName" column="first_name" not-null="true" type="string" /> <property name="lastName" column="last_name" not-null="true" type="string" /> <property name="createdDate" column="created_date" not-null="true" type="timestamp" insert="false" update="false" /> <property name="createdBy" column="created_by" not-null="true" type="string" update="false" /> </class> </hibernate-mapping> I am added a post-update listener. What it will do is if there any updations perfomed on User then it will be invoked and cahnges will be inserted to audit table. Below is the sample implementation for postupdate event. public void onPostUpdate(PostUpdateEvent event) { LogHelper.info(logger, "Begin - onPostUpdate " + event.getEntity().getClass().getSimpleName()); if (!this.checkForAudit(event.getEntity().getClass().getSimpleName())) { // check do we need to audit it. } // Get Attribute Names String[] attrNames = event.getPersister().getEntityMetamodel() .getPropertyNames(); Object[] oldobjectValue = c Object[] newObjectValue = event.getState(); this.auditDetailsEvent(attrNames, oldobjectValue, newObjectValue); LogHelper.info(logger, "End - onPostUpdate"); // return false; } Here is my requirement. event.getPersister().getEntityMetamodel() .getPropertyNames(); or event.getOldState(); or event.getState(); must return attribute names or value which i can update or insert. Is there any way to control the return values of above one's. Pleas help me on this regard. Thanks, Narendra

    Read the article

  • Mapping multiple keys to the same value in a Javascript hash

    - by Bears will eat you
    I use a Javascript hash object to store a set of numerical counters, set up like this [this is greatly simplified]: var myHash = { A: 0, B: 0, C: 0 }; Is there a way to make other keys, ones not explicitly in myHash, map to keys that are? For instance, I'd like [again, this is simplified]: myHash['A_prime']++; // or myHash.A_prime++; to be exactly equivalent to myHash['A']++; // or myHash.A++; e.g. incrementing the value found at the key A, not A_prime.

    Read the article

  • Changing the style attribute of a button according to its state

    - by LambergaR
    I know you can change buttons background by creating a simple XML file, like this: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/button_normal" /> <!-- ... --> </selection> I was wondering if it is possible to use a similar approach to change the style attribute of an element using the same (or similar) technique. Or, if that is not possible, how can the style attribute be changed during runtime (there is no such thing as button.setStyle(R.style.button)).

    Read the article

  • XPath filter not empty attribute

    - by Marcos Buarque
    Hi, I need to filter a XPath expression to grab only a certain attribute as not empty. I tried this: <xsl:template match="DocumentElement/QueryResults[string(@FileName)]"> and this: <xsl:template match="DocumentElement/QueryResults[string-length(@FileName)>0]"> but it did not work. I need the same kind of data returning from the folloing XPath expression... <xsl:template match="DocumentElement/QueryResults"> ... but filtered to avoid items with empty attribute @FileName. Thanks!

    Read the article

  • XDocument change all attribute names

    - by Dested
    I have an XDocument that looks similar to <root> <a> <b foo="1" bar="2" /> <b foo="3" bar="4" /> <b foo="5" bar="6" /> <b foo="7" bar="8" /> <b foo="9" bar="10" /> </a> </root> I wish to change the attribute foo to something else, and the attribute bar to something else. How can I easily do this? My current version (below) stack overflows with large documents, and has an awful smell to it. string dd=LoadedXDocument.ToString(); foreach (var s in AttributeReplacements) dd = dd.Replace(s.Old+"=", s.New+"=");

    Read the article

  • How Can I Reference Multiple Primary Keys For A Vector Type Primary Key

    - by AndreiC
    Hi, I have the following scenario: a table of projects and a table of persons, working on one or serveral projects. Also, I have a project id column (of type int), in the first table, which is a primary key there and I have a vector of project ids, as a column of type int, in my second table (persons), that references primary keys from the first table. What is the correct syntax for referencing multiple primary keys, from a vector foreign key. This is the way I am trying to create the table, but I am not sure what to place at the indicated line: CREATE TABLE Persons( Person_Id int, ..., ProjectsList int[], FOREIGN KEY (ProjectsList) REFERENCES Projects(Project_id) -- not sure what how to define the link here ); I hope my explanations are not over-complicated. Thank you in advance for helping!

    Read the article

  • Regexp to add attribute in any xml tags

    - by katsuo11
    Hello, I have well-formed xml documents into string variables. I want to use preg_replace to add a defined attribute to every xml tags. For example replace: <tag1> <tag2> some text </tag2> </tag1> by: <tag1 attr="myAttr"> <tag2 attr="myAttr"> some text </tag2> </tag1> So I basically need the regex expression to find any start tags and add my attribute, but I'm a complete regex noob. Thanks, kats

    Read the article

  • Saving model object in django throws no error but attribute value doesn't change

    - by Pilgrim
    Hi. I get a model object, change an attribute, save it and it still has the old attribute: >>> g = SiteProfile.objects.get(pk=3) >>> g.renew_date datetime.date(2010, 4, 11) >>> g.renew_date = date.today()+timedelta(days=365) >>> g.renew_date datetime.date(2011, 4, 11) >>> g.save() >>> g.renew_date datetime.datetime(2010, 4, 11, 16, 57, 4, 192684) Anyone know if this is an issue with the database or something else?

    Read the article

  • XML Parsing in Groovy strips attribute new lines

    - by Bill James
    I'm writing code where I retrieve XML from a web api, then parse that XML using Groovy. Unfortunately, it seems that both XmlParser and XmlSlurper for Groovy strip newline characters from the attributes of nodes when .text() is called. How can I get at the text of the attribute including the newlines? Sample code: def xmltest = ''' <snippet> <preSnippet att1="testatt1" code="This is line 1 This is line 2 This is line 3" > <lines count="10" /> </preSnippet> </snippet>''' def parsed = new XmlParser().parseText( xmltest ) println "Parsed" parsed.preSnippet.each { pre -> println pre.attribute('code'); } def slurped = new XmlSlurper().parseText( xmltest ) println "Slurped" slurped.children().each { preSnip -> println [email protected]() } the output of which is: Parsed This is line 1 This is line 2 This is line 3 Slurped This is line 1 This is line 2 This is line 3

    Read the article

  • Trying to verify understanding of Foreign Keys MSSQL

    - by msarchet
    So I'm working on just a learning project to expose myself to doing some things I do not get to do at work. I'm just making a simple bug and case tracking app (I know there are a million this is just to work with some tools I don't get to). So I was designing my database and realized I've never actually used Foreign Keys before in any of my projects, I've used them before but never actually setting up a column as a FK. So I've designed my database as follows, which I think is close to correct (at least for the initial layout). However When I try to add the FK's to the linking Tables I get an error saying, "The tables present in the relationship must have the same number of columns". I'm doing this by in SQLSMS by going to the Keys 'folder' and adding a FK. Is there something that I am doing wrong here, I don't understand why the tables would have to have the same number of columns for me to add a FK relationship between the tables?

    Read the article

  • An appropriate C API for inspecting attribute values

    - by uk82
    There are two obvious ways in C to provide outside access to internal attribute values (A) provide a generic interface that accepts a list of attributes that changes over time (some added / some die) or (B) a specific interface for each and every attribute. Example A: int x_get_attribute_value(ATT att) { if (a) return a_val; if (b) return b_val; } Example B: A_Enum x_get_a_type_attribute() {} B_Enum x_get_b_type_attribute() {} I recall that Eclipse's API is very much like A (I could be wrong). What I can't do is come up with a compelling argument against either. A is clean - any user will no where to go to find out a property value. It can evolve cleanly without leaving dead interfaces around. B has type checking to a degree - this is C enums! Is there a big hitter argument that pushes the balance away from opinion?

    Read the article

  • Return specific HREF attribute using Xpath query

    - by Michael Pasqualone
    Having a major brain freeze, I have the following chunk of code: // Get web address $domQuery = query_HtmlDocument($html, '//a[@class="productLink"]'); foreach($domQuery as $rtn) { $web = $rtn->getAttribute('href'); } Which obviously gets the entire href attribute, however I only want 1 specific attribute within the href. I.e. If the href is: /website/product1234.do?code=1234&version=1.3&somethingelse=blaah I only want to return the variable for "version", so wish to only return "1.3" in my example. What's most efficient way to do this?

    Read the article

  • How to get attribute of a model saved in instance variable

    - by Nazar
    I am writing a plugin, in which i define a new relation dynamically with in plugin. Sample code is given below module AttachDocumentsAs @as = nil def attach_documents_as(*attachment_as) attachment_as = attachment_as.to_a.flatten.compact.map(&:to_sym) @as = attachment_as.first class_inheritable_reader(@as) class_eval do has_many @as, :as => :attachable, :class_name=>"AttachDocuments::Models::AttachedDocument" accepts_nested_attributes_for @as end end end now in any model i used it as class Person < AtiveRecord::Base attach_documents_as :financial_documents end Now want to access want to access this attribute of the class in overloaded initialize method like this def initialize(*args) super(*args) "#{@as}".build end But it is not getting required attribute, can any one help me in it. I want to build this relation and set some initial values. Waiting for guidelines from all you guys.

    Read the article

  • DisplayName attribute from Resources?

    - by Palantir
    Hello! I have a localized application, and I am wondering if it is possible to have the DisplayName for a certain model property set from a Resource. I'd like to do something like this: public class MyModel { [Required] [DisplayName(Resources.Resources.labelForName)] public string name{ get; set; } } But I can't to it, as the compiler says: "An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type" :( Are there any workarounds? I am outputting labels manually, but I need these for the validator output!

    Read the article

  • How to retrieve XML attribute for custom control

    - by David
    I've created a combo box control with a edittext and spinner. I'm trying to let the android:prompt attribute be passed onto the spinner, which means I need to catch it in the constructor which passes my the AttributeSet and set it on the spinner. I can't figure out how to get the value of the prompt. I'm trying, int[] ra = { android.R.attr.prompt }; TypedArray ta = context.getTheme().obtainStyledAttributes(ra); int id = ta.getResourceId(0, 0); I get back 0, which means it didn't find the attribute. I also did a ta.count() which returned 0. So I'm not getting anything back. My XML simply defines an android:prompt value. Thanks

    Read the article

  • How are CD Keys generated?

    - by The Rook
    CD Keys are the defacto-standard as an anti-piracy measure. To be honest this strikes me as Security Though Obscurity, although I really have no idea how CD Keys are generated. What is a good (secure) example of CD Key generation? What cryptographic primitive (if any) are they using? Is it a message digest? If so what data would they be hashing? What methods do developers employ to make it difficult for crackers to build their own key generators?

    Read the article

  • parsing xml attribute value

    - by vbNewbie
    I have been parsing xml content using the xmlreader and cannot use the xml document but so far it works getting all elementcontent except for the attribute contents. I need to parse the link below found in the following entry; <title>XXXX UUUUUU posted a</title> <category term="NotePosted" label="Note Posted"/> <link rel="alternate" type="html" href="http://www.dfsddsfdsf.com/profile.php?id=sdfdfsfdsdfddfsfd&amp;v=wall&amp;story_dbid=dssdfasdfdasfdsafafafa"/> <source>......... <source> I need the href tag in the link attribute but it keeps coming back null. While ureader.Read If ureader.HasAttributes Then fId = ureader.GetAttribute("href") If fId.Contains("?v=wall&amp") Then fIdList.Add(fId) Exit While End If If String.IsNullOrEmpty(fId) Then fId = "NOTHING" End If End If End While

    Read the article

  • Drupal - Use lightbox with Views (Rel attribute) - in output link

    - by kilrizzy
    In Drupal I have two image fields, one to act as a thumbnail and the other the image that will open when the thumbnail is clicked. The only way I could find to link the two was to use the option for "Output this field as a link" and link to the image field. This works, so when I click the thumbnail it opens the larger image however I would like to use lightbox2 for this task but in the "Output this field as a link" options there is no way to set the "rel" attribute. Is there a way to either set the rel attribute or invoke the lightbox by setting a class?

    Read the article

  • Format attribute of <bean:write> tag in Struts

    - by Sushant Taneja
    Hello All, I am developing a web application using Struts 1.2.7 I want to print a list of integers using the tag. I searched and found that the format attribute is used to print the desired result but was unsuccessful. What should I pass as the value in format to print 3 digit integers/floating point numbers. The code sample is as follows: <logic:iterate name="intList" id="integer" > <bean:write name="integer" /> <logic:iterate /> Here intList is a List of int(s) passed as a request attribute to the jsp page under consideration.

    Read the article

< Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >