Search Results

Search found 15316 results on 613 pages for 'coding style'.

Page 62/613 | < Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >

  • reddit style voting with django

    - by dotty
    Hay i need to hand implemeneting a voting system into a model. I've had a huge helping hand from Mike DeSimone making this work in the first place, but i need to expand upon his work. Here is my current code View def show_game(request): game = Game.objects.get(pk=1) discussions = game.gamediscussion_set.filter(reply_to=None) d = { 'game':game, 'discussions':discussions } return render_to_response('show_game', d) Template <ul> {% for discussion in discussions %} {{ discussion.html }} {% endfor %} </ul> Model class GameDiscussion(models.Model): game = models.ForeignKey(Game) message = models.TextField() reply_to = models.ForeignKey('self', related_name='replies', null=True, blank=True) created_on = models.DateTimeField(blank=True, auto_now_add=True) userUpVotes = models.ManyToManyField(User, blank=True, related_name='threadUpVotes') userDownVotes = models.ManyToManyField(User, blank=True, related_name='threadDownVotes') def html(self): DiscussionTemplate = loader.get_template("inclusions/discussionTemplate") return DiscussionTemplate.render(Context({ 'discussion': self, 'replies': [reply.html() for reply in self.replies.all()] })) DiscussionTemplate <li> {{ discussion.message }} {% if replies %} <ul> {% for reply in replies %} {{ reply }} {% endfor %} </ul> {% endif %} </li> As you can see we have 2 fields userUpVotes and userDownVotes on the model, these will calculate how to order the discussions and replies. How would i implement these 2 fields to order the replies and discussions based on votes? Any help would be great!

    Read the article

  • How to parse a custom XML-style error code response from a website

    - by user1870127
    I'm developing a program that queries and prints out open data from the local transit authority, which is returned in the form of an XML response. Normally, when there are buses scheduled to run in the next few hours (and in other typical situations), the XML response generated by the page is handled correctly by the java.net.URLConnection.getInputStream() function, and I am able to print the individual results afterwards. The problem is when the buses are NOT running, or when some other problem with my queries develops after it is sent to the transit authority's web server. When the authority developed their service, they came up with their own unique error response codes, which are also sent as XMLs. For example, one of these error messages might look like this: <Error xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Code>3005</Code> <Message>Sorry, no stop estimates found for given values.</Message> </Error> (This code and similar is all that I receive from the transit authority in such situations.) However, it appears that URLConnection.getInputStream() and some of its siblings are unable to interpret this custom code as a "valid" response that I can handle and print out as an error message. Instead, they give me a more generic HTTP/1.1 404 Not Found error. This problem cascades into my program which then prints out a java.io.FileNotFoundException error pointing to the offending input stream. My question is therefore two-fold: 1. Is there a way to retrieve, parse, and print a custom XML-formatted error code sent by a web service using the plugins that are available in Java? 2. If the above is not possible, what other tools should I use or develop to handle such custom codes as described?

    Read the article

  • WPF data grid for financial style reporting?

    - by user191254
    Hello, I'm looking for a decent WPF data grid or solution involving one to represent financial data. I've looked at many - the WPF one, XCeed, Ingragistics, DevExpress, etc.... but none of them seem to offer the simple requirement I have: I want to be able to display group subtotals in their columns in the group row, e.g. GROUP 1 xxxx.xx GROUP 2 xxxx.xx ROW 1 xx.xx ROW 2 xx.xx Does anyone know of a grid that does this, or a nice supporting collection that implements aggregate functions (group totals would need to be used in individual line items) so that existing grids with a bit of XAML styling would work? Thanks in advance, Stephen

    Read the article

  • Creating a "netbeans property" style dialog box

    - by pikco
    Hi I've been trying to create a GUI using netbeans, that includes a dialog similar to Netbean's own "property dialog" that appears when designing. ie. a dialog that contains a table that can be expanded by tree nodes. Something like the dialog on this page, http://platform.netbeans.org/tutorials/nbm-property-editors.html As far as I can understand, the page I linked to describes a custom editor I can set up for use within netbeans while designing - I'm just looking for a way to doing something similar for my actual application I'm writing. Is there an easy way to do this? I came across this and have tried it but it doesn't quite work in the same way as the standard Netbeans dialog. weblogs.java.net/blog/timboudreau/archive/2008/06/egads_an_actual.html Any tips greatly appreciated.

    Read the article

  • Applying style sheets in pyqt

    - by Jebagnanadas
    Hello all, If i apply a property to a parent widget it is automatically applied for child widgets too.. Is there any way of preventing this?? For example if i set background color as white in a dialog the button,combo boxes and scroll bars looks white as it lacks it native look(have to say it's unpleasant & ugly).. Is there any way that i can apply the stylesheets only to a parent widget not to it's children??? Experts help please..

    Read the article

  • How do i pack multiple rectangles in a 2d box tetris style

    - by mglmnc
    I have a number of rectangles of various widths and heights. I have a larger rectangular platform to put them on. I want to pack them on one side of the platform so they spread in the lengthwise (X) dimension but keep the widthwise (Y) dimension to a minimal. That is to place them like a tetris game. There can be no overlaps but there can be gaps. Is there an algorithm out there to do this?

    Read the article

  • Theme change doesn't work on <4.0 as it should

    - by user1717276
    I have some difficulties with setting up a "theme switcher" programmatically. I would like to switch themes from app (between White (Theme.Light.NoTitleBar) and Dark (Theme.Black.NoTitleBar)) and what I do is: I set a SharedPreference: final String PREFS_NAME = "MyPrefsFile"; final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); final SharedPreferences.Editor editor = settings.edit(); and than I have a two buttons to switch themes (second one is almost identical) Button ThemeWhite = (Button) findViewById(R.id.ThemeWhite); ThemeWhite.setOnClickListener(new OnClickListener() { public void onClick(View v) { editor.putBoolean("Theme", false); editor.commit(); System.exit(2); } }); and in begging of each activity I check SharedPreference boolean theme = settings.getBoolean("Theme", false); if(theme){ this.setTheme(R.style.Theme_NoBarBlack); } else{ this.setTheme(R.style.Theme_NoBar); } setContentView(R.layout.aplikacja); I define themes in file styles.xml in folder values: <resources> <style name="Theme.NoBar" parent="@android:style/Theme.Light.NoTitleBar" /> <style name="Theme.NoBarBlack" parent="@android:style/Theme.NoActionBar" /> in values-v11: <resources> <style name="Theme.NoBar" parent="@android:style/Theme.Holo.Light.NoActionBar" /> <style name="Theme.NoBarBlack" parent="@android:style/Theme.Holo.NoActionBar" /> in values-v14: <resources> <style name="Theme.NoBar" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar" /> <style name="Theme.NoBarBlack" parent="@android:style/Theme.DeviceDefault.NoActionBar" /> manifest file: <application android:theme="@style/Theme.NoBar" > Everything is working excellent on android 4.0 but when I use 2.2 it doesn't change theme - just font is getting white as it should be but there is no dark background. I tried checking if it at least works and changed Theme.NoBarBlack in values (for android <3.0) and its value the same as Theme.NoBar and then when I pressed button font wasn't changed -as it should do.

    Read the article

  • Wizard style navigation, dismissing a view and showing another one

    - by Robin Jamieson
    I'm making a set of screens similar to a wizard and I'd like to know how to make a view dismiss itself and its parent view and immediately show a 'DoneScreen' without worrying about resource leaks. My views look like the following: Base -> Level1 -> DoneScreen -> Level2 -> DoneScreen The Level1 controller is a navigation controller created with a view.xib and shown with [self presentModalViewController ...] by the Base controller. The Level1 controller is also responsible for creating the 'DoneScreen' which may be shown instead of the Level2 Screen based on a certain criteria. When the user taps a button on the screen, the Level1 controller instantiates the the Level2 controller and it displays it via [self.navigationController pushViewController ..] and Level2 controller's view has a 'Next' button. When the use hits the 'Next' button in the Level2 screen, I need to dismiss the current Level2's view as well as the Level1's view and display the 'DoneScreen', which would have been created and passed in to the Level2 controller from Level1. (partly to reduce code duplication, and partly to separate responsibilities among the controllers) In the Level2 controller, if I show the 'DoneScreen' first and dismiss itself with [self.navigationController popViewControllerAnimated:YES]; then the Level1 controller's modal view is still present above the 'Base' but under the Done screen. What's a good way to clear out all of these views except the Base and then show the 'DoneScreen'? Any good suggestions on how to get this done in a simple but elegant manner?

    Read the article

  • Change Style/Look of Asp:CheckBox using CSS

    - by KiwiBastard
    I want to change the standard "3D" look of the standard asp.net checkbox to say solid 1px. If I try to apply the styling to the Border for example it does just that - draws the standard checkbox with a border around it - which is valid I guess. Anyway, is there a way to change how the actual textbox is styled?

    Read the article

  • Link XSL Style Sheet to XForms generated XML document

    - by iHeartGreek
    Hi! Through XForms, I generate an XML document. I need this XML document to be transformed by a specific XSL. How do I link the XSL to the XML through XForms? Example of link: <?xml-stylesheet type="text/xsl" href="test.xsl"?> (The XML doc gets regenerated every time the XForms submits to it.. so I cannot hardcode the link in the XML doc, in needs to be done through the XForms) Thanks!

    Read the article

  • CKEditor configuration, prefer img tag atrributes over inline style

    - by Unreason
    On su it was suggested to ask this here... Looking for a way to disable a feature in CKEditor that messes with attributes height and width on my and converts them into inline styles. The version of CKEditor is 3.2 and I have access to config files. Along the same lines is there somewhere an overview (or procedure) for changing the way CKEditor produces html (I'd like to force it to do inline styles; except for images, plus some other changes) Thank you for taking the time to read this

    Read the article

  • Migrate style from TabItem to TabHeader

    - by OffApps Cory
    Good day! I have a TabControl with TabItems that have been customized via a control template. This control template specifies a trigger whereby on mouseover, the content of tab header grows slightly. <ControlTemplate> <Storyboard x:Key="TabHeaderGrow"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TabName" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"> <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="TabName" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"> <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> <ControlTemplate.Triggers> <EventTrigger RoutedEvent="Mouse.MouseEnter"> <BeginStoryboard Storyboard="{StaticResource TabHeaderGrow}"/> </EventTrigger> When I mouseover any of the tabs they work as expected, however the trigger also fires when I mouseover any of the elements in the tab body. I know that I need to migrate the control styling to a tabHeader controlTemplate, but I am unsure how to do that. I can't seem to do template binding for the content of the tabheader. Any help would be appreciated.

    Read the article

  • Drupal6: How to programmatically style a block?

    - by Fronker
    In Drupal6, I basically have a block (a hierarchical menu structure) that turns out like this in HTML: <div class="block block-menu_block" id="block-menu_block-1"> <div class="content"> <div class="menu-block-1 menu-name-menu-navigation parent-mlid-0 menu-level-1"> <ul class="menu"> <li class="leaf first menu-mlid-248 active active-trail"><a class="active-trail active" title="" href="/">Start</a></li> <li class="expanded menu-mlid-249 active"><a class="active" title="" href="/">Aktuell</a> <ul class="menu"> <li class="leaf first menu-mlid-259"> <a title="News und Presse" href="/news-und-presse">News and Press</a> </li>... What I would like to get is actually a lot simpler: <div id="topmenu"> <ul class="one"> <li>some main entry <ul> <li> some sub entry ... or maybe: <div id="topmenu"> <h2>some main entry</h2> <h3><a href="#">some sub entry</a></h3> <h3><a href="#">another sub entry</a></h3> <h2>another main entry</h2> So, keeping the structure, but being able to use simpler, even completely different tags, if and when needed. I think I understand from the drupal docs, that I am (maybe) looking at <div class="block block-menu_block" id="block-menu_block-1" ==> module := menu_block delta := 1 (?) regrettably, none of the suggested * block-[module]-[delta].tpl.php * block-[module].tpl.php * block-[region].tpl.php placed next to page.tpl.php has any impact (yes, I did clear the cache).

    Read the article

  • [Wordpress] How do you remove a Category-style (hierarchical) taxonomy metabox

    - by Manny Fleurmond
    I was wondering if someone can help me with this. I'm currently following Shibashake's tutorial about creating custom meta-boxes that include taxonomy selection here: http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels . They show how to remove the standard metabox Wordpress automatically creates for taxonomies using the remove_meta_box function. Only problem is that the function for some reason doesn't seem to work on taxonomies that work as categories ie ones where the hierarchical option is set to true. I know I have the function working because the ones set up as tags disappear easily enough. I can't if it just isn't possible or if there is something special I need to add in one of the parameters to make it work. Example: $args = array( 'hierarchical' => false, 'label' =>'People', 'query_var' => true, 'rewrite' => true ); register_taxonomy('people', 'post',$args); remove_meta_box('tagsdiv-people','post','side'); That works fine. If I set hierarchical to 'true, however, the meta box stays put. Can anyone shed some light?

    Read the article

  • .net, using PowerShell class to invoke a "[namespace.class]::method" style command

    - by Marco
    Hello, I created a powershell object via .net to invoke commands. When I invoke normal commands like 'Get-Process' I had no problems: ps.AddCommand("Get-Process").AddParameter(...).Invoke() but I'm not able to invoke a .net method with the syntax "[namespace.class]::method", just to make an example to invoke [System.IO.File]::Exists("c:\boo.txt"). I tried with ps.AddCommand("[System.IO.File]::Exists(\"c:\boo.txt\")").Invoke() ps.AddCommand("[System.IO.File]::Exists").AddArgument("c:\boo.txt\").Invoke() and some others. It always throws an exception which says that the command specified is not recognized. There is a way to invoke that type of command? Thanks

    Read the article

  • Browser PDF File Previwer(Google Style)

    - by Odero Kennedy
    Hi All, I am working on an application which needs to preview privileged content in the browser. The preview should work in a way that its NOT possible to download the content. Only reading within the browser is allowed. I have looked at google docs preview but it needs the url of the docs to accessible online. I need to work with content in the intranet The previewer should not mandate the installation of a pluggin as this would limit the access. Any hints

    Read the article

  • jQuery - iGoogle style interface

    - by samhamilton
    Hi all, I'm currently working on developing a customizable website layout using jQuery, so I can drag, drop, add and remove blocks of content... much like the iGoogle interface. I have my blocks dragging and dropping working with 3 columns of content My question is to do with adding and removing blocks If I use hide(), I can simply hide and show the blocks. If I use remove, I would have to append the list of blocks to load in a new block into a column. I'm not sure which is the best approach to take. I'd be grateful for any advice on best practise, i.e. to hide() or remove() and any other advice on building this kind of interface. Thank, Sam.

    Read the article

  • Accomplishing This Style of Drop-Down Menus in jQuery

    - by Maxim Z.
    I was browsing the web and found this site. I noticed how the nav bar drop-down works, and I want to implement something similar on my website. Afer going into the source code of the page, I found that those drop-down areas are contained in divs with class fOut. It turns out that this is being done with MooTools. Here is the script itself (referenced in the original page after the Mootools script itself): window.addEvent('domready', function() { $("primaryNav").getChildren("li").addEvents({ "mouseenter": function(){ $(this).addClass("hover").getChildren("a").addClass("hover"); }, "mouseleave": function(){ $(this).removeClass("hover").getChildren("a").removeClass("hover"); } }); $$(".fOut").each(function(el,i){ var ifr = $(document.createElement("iframe")); ifr.className = "ieBgIframe"; ifr.frameBorder = "0"; ifr.src="about:blank"; ifr.injectInside(el); var p = el.getParent(); p.addClass("hover"); var h = el.getSize().size.y; p.removeClass("hover"); ifr.height=h; }); $$(".olderVersionsToggle").addEvents({ "click": function(e){ var event = new Event(e); event.stop(); var p = $(this).getParent().getNext(); if(p.hasClass("open")){ p.removeClass("open"); $(this).setText("Show previous versions..."); } else{ p.addClass("open"); $(this).setText("Hide previous versions..."); } return false; } }); }); My Question(s) I have two questions about this code. How does it work? I don't quite understand what it's doing, with the iframes and all. How can this be implemented in jQuery?

    Read the article

  • code style for private methods in c#

    - by illdev
    I just found out, that it seems a common pattern to user UpperFirstLetterPascalCase() for private methods. I for myself, find this completely inconsistent with naming rules of private instance fields and variables and I find it difficult to read/debug, too. I would want to ask, why using a first upper letter for methods could be a better choice than a first lower (doThis())? Just out of curiosity...

    Read the article

  • Good style for handling constructor failure of critical object

    - by mtlphil
    I'm trying to decide between two ways of instantiating an object & handling any constructor exceptions for an object that is critical to my program, i.e. if construction fails the program can't continue. I have a class SimpleMIDIOut that wraps basic Win32 MIDI functions. It will open a MIDI device in the constructor and close it in the destructor. It will throw an exception inherited from std::exception in the constructor if the MIDI device cannot be opened. Which of the following ways of catching constructor exceptions for this object would be more in line with C++ best practices Method 1 - Stack allocated object, only in scope inside try block #include <iostream> #include "simplemidiout.h" int main() { try { SimpleMIDIOut myOut; //constructor will throw if MIDI device cannot be opened myOut.PlayNote(60,100); //..... //myOut goes out of scope outside this block //so basically the whole program has to be inside //this block. //On the plus side, it's on the stack so //destructor that handles object cleanup //is called automatically, more inline with RAII idiom? } catch(const std::exception& e) { std::cout << e.what() << std::endl; std::cin.ignore(); return 1; } std::cin.ignore(); return 0; } Method 2 - Pointer to object, heap allocated, nicer structured code? #include <iostream> #include "simplemidiout.h" int main() { SimpleMIDIOut *myOut; try { myOut = new SimpleMIDIOut(); } catch(const std::exception& e) { std::cout << e.what() << std::endl; delete myOut; return 1; } myOut->PlayNote(60,100); std::cin.ignore(); delete myOut; return 0; } I like the look of the code in Method 2 better, don't have to jam my whole program into a try block, but Method 1 creates the object on the stack so C++ manages the object's life time, which is more in tune with RAII philosophy isn't it? I'm still a novice at this so any feedback on the above is much appreciated. If there's an even better way to check for/handle constructor failure in a siatuation like this please let me know.

    Read the article

  • Cross-platform GUI toolkits with WPF-style composition capabilities

    - by Alexey Romanov
    A huge advantage of WPF over, say, WinForms is its composability. To quote Programming WPF: One level up, WPF provides its “content model,” which allows any control to host any group of other controls. You don’t have to build special BitmapButton or IconComboBox classes; you put as many images, shapes, videos, 3D models, or whatever into a Button (or a ComboBox, ListBox, etc.) as suit your fancy. Are there any cross-platform GUI frameworks (preferably with Java bindings) out there which also let you do this?

    Read the article

  • Combobox item style

    - by user373721
    my project is asp.net MVC, using Telerik MVC combobox. I can change the sytle of the first item if I use: var item = combobox.dropDown.$items.first(); item.addClass('test'); Or change all items, using: combobox.dropDown.$items.addClass('test'); But I need to change just specific items (based on a model), I tried: combobox.dropDown.$items[1].addClass('test'); I get this error: Object doesn't support property or method 'addClass'

    Read the article

  • webOS style view switching on iPhone app

    - by Taylor Satula
    Hello, I have been working with a iPhone app that I would like to have switch views like the Palm Pre does for multitasking. I know the usual way of switching views by using the black bar at the bottom of the app but the app I am working on does not lend itself to having a big black bar in the way (see attached picture #1). I guess my question is, how do I shrink the current view (Current Location window) and show other views on the sides? (see attached picture #2) Then be able to swipe left and right to view other views. I have no idea how to do this and would be eternally grateful if someone could help me out with this. http://www.threepixeldrift.com/images/deep-storage/webOScardapp1.jpg http://www.threepixeldrift.com/images/deep-storage/webOScardapp2.jpg

    Read the article

< Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >