Daily Archives

Articles indexed Thursday August 30 2012

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

  • HUD layer not being added on my scene

    - by Shailesh_ios
    I have a CCScene which already holds my gameLayer and I am trying to add HUD layer on that.But the HUD layer is not getting added in my scene, I can say that because I have set up a CCLabel on HUD layer and when I run my project, I cannot see that label. Here's what I am doing : In my gameLayer: +(id) scene { CCScene *scene = [CCScene node]; GameScreen *layer = [GameScreen node]; [scene addChild: layer]; HUDclass * otherLayer = [HUDclass node]; [scene addChild:otherLayer]; layer.HC = otherLayer;// HC is reference to my HUD layer in @Interface of gameLayer return scene; } And then in my HUD layer I have just added a CCLabelTTF in its init method like this : -(id)init { if ((self = [super init])) { CCLabelTTF * label = [CCLabelTTF labelWithString:@"IN WEAPON CLASS" fontName:@"Arial" fontSize:15]; label.position = ccp(240,160); [self addChild:label]; } return self; } But now when I run my project I dont see that label, What am I doing wrong here ..? Any Ideas.. ? Thanks in advance for your time.

    Read the article

  • Inventory Management concepts in XNA game

    - by user1332755
    I am trying to code the inventory system in my first real game so I have very little experience in both c# and game engine development. Basically, I need some general guidance and tips with how to structure and organize these sorts of systems. Please tell me if I am on the right track or not before I get too deep into making some badly structured system. It's fine if you don't feel like looking through my code, suggestions about general structure would also be appreciated. What I am aiming to end up with is some sort of system like Minecraft or Terraria. It must include: main inventory GUI (items can be dragged and placed in whatever slot desired Itembar outside of the main inventory which can be assigned to certain items the ability to use items from either location So far, I have 4 main classes: Inventory holds the general info and methods, inventoryslot holds info for individual slots, Itembar holds all info and methods for itself, and finally, ItemManager to manage interactions between the two and hold a master list of items. So far, my itembar works perfectly and interacts well with mousedragging items into and out of it as well as activating the item effect. Here is the code I have so far: (there is a lot but I will try to keep it relevant) This is the code for the itembar on the main screen: class Itembar { public Texture2D itembarfull, iSelected; public static Rectangle itembar = new Rectangle(5, 218, 40, 391); public Rectangle box1 = new Rectangle(itembar.X, 218, 40, 40); //up to 10 Rectangles for each slot public int Selected = 0; private ItemManager manager; public Itembar(Texture2D texture, Texture2D texture3, ItemManager mann) { itembarfull = texture; iSelected = texture3; manager = mann; } public void Update(GameTime gametime) { } public void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw( itembarfull, new Vector2 (itembar.X, itembar.Y), null, Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 1.0f); if (Selected == 1) spriteBatch.Draw(iSelected, new Rectangle(box1.X-3, box1.Y-3, box1.Width+6, box1.Height+6), Color.White); //goes up to 10 slots } public int Box1Query() { foreach (Item item in manager.items) { if(box1.Contains(item.BoundingBox)) return manager.items.IndexOf(item); } return 999; } //10 different box queries It is working fine right now. I just put an Item in there and the box will query things like the item's effects, stack number, consumable or not etc...This one is basically almost complete. Here is the main inventory class: class Inventory { public bool isActive; public List<Rectangle> mainSlots = new List<Rectangle>(24); public List<InventorySlot> mainSlotscheck = new List<InventorySlot>(24); public static Rectangle inv = new Rectangle(841, 469, 156, 231); public Rectangle invfull = new Rectangle(inv.X, inv.Y, inv.Width, inv.Height); public Rectangle inv1 = new Rectangle(inv.X + 4, inv.Y +3, 32, 32); //goes up to inv24 resulting in a 6x4 grid of Rectangles public Inventory() { mainSlots.Add(inv1); mainSlots.Add(inv2); mainSlots.Add(inv3); mainSlots.Add(inv4); //goes up to 24 foreach (Rectangle slot in mainSlots) mainSlotscheck.Add(new InventorySlot(slot)); } //update and draw methods are empty because im not too sure what to put there public int LookforfreeSlot() { int slotnumber = 999; for (int x = 0; x < mainSlots.Count; x++) { if (mainSlotscheck[x].isFree) { slotnumber = x; break; } } return slotnumber; } } } LookforFreeSlot() method is meant to be called when I do AddtoInventory(). I'm kinda stumped about what other things I need to put in this class. Here is the inventorySlot class: (its main purpose is to check the bool "isFree" to see whether or not something already occupies the slot. But i guess it can also do other stuff like get item info.) class InventorySlot { public int X, Y; public int Width = 32, Height = 32; public Vector2 Position; public int slotnumber; public bool free = true; public int? content = null; public bool isFree { get { return free; } set { free = value; } } public InventorySlot(Rectangle slot) { slot = new Rectangle(X, Y, Width, Height); } } } Finally, here is the ItemManager (I am omitting the master list because it is too long) class ItemManager { public List<Item> items = new List<Item>(20); public List<Item> inventory1 = new List<Item>(24); public List<Item> inventory2 = new List<Item>(24); public List<Item> inventory3 = new List<Item>(24); public List<Item> inventory4 = new List<Item>(24); public Texture2D icon, filta; private Rectangle msRect; MouseState mouseState; public int ISelectedIndex; Inventory inventory; SpriteFont font; public void GenerateItems() { items.Add(new Item(new Rectangle(0, 0, 32, 32), icon, font)); items[0].name = "Grass Chip"; items[0].itemID = 0; items[0].consumable = true; items[0].stackable = true; items[0].maxStack = 99; items.Add(new Item(new Rectangle(32, 0, 32, 32), icon, font)); //master list continues. it will generate all items in the game; } public ItemManager(Inventory inv, Texture2D itemsheet, Rectangle mouseRectt, MouseState ms, Texture2D fil, SpriteFont f) { icon = itemsheet; msRect = mouseRectt; filta = fil; mouseState = ms; inventory = inv; font = f; } //once again, no update or draw public void mousedrag() { items[0].DestinationRect = new Rectangle (msRect.X, msRect.Y, 32, 32); items[0].dragging = true; } public void AddtoInventory(Item item) { int index = inventory.LookforfreeSlot(); if (index == 999) return; item.DestinationRect = inventory.mainSlots[index]; inventory.mainSlotscheck[index].content = item.itemID; inventory.mainSlotscheck[index].isFree = false; item.IsActive = true; } } } The mousedrag works pretty well. AddtoInventory doesn't work because LookforfreeSlot doesn't work. Relevant code from the main program: When I want to add something to the main inventory, I do something like this: foreach (Particle ether in ether1.ethers) { if (ether.isCollected) itemmanager.AddtoInventory(itemmanager.items[14]); } This turned out to be much longer than I had expected :( But I hope someone is interested enough to comment.

    Read the article

  • how do you group select_tag and text_field_tag?

    - by Eytan
    I'm trying to build a form where a user can select an existing category, or define their own. My form looks something like this... <%= f.select :category, category_options, prompt: "Select"> <%= f.text_field :category %> However, this UI is confusing. The user can select something in the select box, and type in a custom category. In this case, the final result is not obvious. Do you guys have any recommendations on how to handle this situation?

    Read the article

  • Sort ranges in an array in google apps script

    - by user1637113
    I have a timesheet spreadsheet for our company and I need to sort the employees by each timesheet block (15 rows by 20 columns). I have the following code which I had help with, but the array quits sorting once it comes to a block without an employee name (I would like these to be shuffled to the bottom). Another complication I am having is there are numerous formulas in these cells and when I run it as is, it removes them. I would like to keep these intact if at all possible. Here's the code: function sortSections() { var activeSheet = SpreadsheetApp.getActiveSheet(); //SETTINGS var sheetName = activeSheet.getSheetName(); //name of sheet to be sorted var headerRows = 53; //number of header rows var pageHeaderRows = 5; //page totals to top of next emp section var sortColumn = 11; //index of column to be sorted by; 1 = column A var pageSize = 65; var sectionSize = 15; //number of rows in each section var col = sortColumn-1; var sheet = SpreadsheetApp.getActive().getSheetByName(sheetName); var data = sheet.getRange(headerRows+1, 1, sheet.getMaxRows()-headerRows, sheet.getLastColumn()).getValues(); var data3d = []; var dataLength = data.length/sectionSize; for (var i = 0; i < dataLength; i++) { data3d[i] = data.splice(0, sectionSize); } data3d.sort(function(a,b){return(((a[0][col]<b[0][col])&&a[0][col])?-1:((a[0][col]>b[0][col])?1:0))}); var sortedData = []; for (var k in data3d) { for (var l in data3d[k]) { sortedData.push(data3d[k][l]); } } sheet.getRange(headerRows+1, 1, sortedData.length, sortedData[0].length).setValues(sortedData);

    Read the article

  • css issue on hover- shaky effect

    - by Sarika Thapaliya
    <style type="text/css"> .linkcontainer{border-right: solid 0.2px white;margin-right:1px} .hardlink{color: #FFF !important; border: 1px solid transparent; } .hardlink:hover{ background:url("/_layouts/images/bgximg.png") repeat-x -0px -489px; display:inline-block; background-color:#21374C; border:0.2px solid #5badff; line-height:20px; text-decoration:none !important;} </style> <div style="padding-bottom:3px;background:transparent; color:white!important; float:left; margin-right:20px; line-height:42px;"> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px;" href="http://hronline">HROnline</a> </span> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px; " href="http://hronline/ec">Employee Center</a> </span> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px; " href="http://hronline/businesscommunities">Business Communities</a> </span> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px;" href="http://hronline/internalservices">Internal Services</a> </span> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px;" href="http://hronline/policiesprocedures">Policies&procedures</a> </span> <span class="linkcontainer"> <a class="hardlink" style="padding:0 10px;" href="http://hronline/qualitybestpractices">Best Practices</a> </span> </div> I added a right border to the span that contain menu links. When I hover on each menu links, it also has some background. This is causing jerky effect on the whole container.. What is causing the shaky effect on hover? I don't seem to figure it out--again..

    Read the article

  • Strategy for Storing Multiple Nullable Booleans in SQL

    - by Eric J.
    I have an object (happens to be C#) with about 20 properties that are nullable booleans. There will be perhaps a few million such objects persisted to a SQL database (currently SQL Server 2008 R2, but MySQL may need to be supported in the future). The instances themselves are relatively large because they contain about a paragraph of text as well as some other unrelated properties. For a given object instance, most of the properties will be null most of the time. When users search for instances of such objects, they will select perhaps 1-3 of the nullable boolean properties and search for instances where at least one of those 1-3 properties is non-null (OR search). My first thought is to persist the object to a single table with nullable BIT columns representing the nullable boolean properties. However, this strategy will require one index per BIT column to avoid performing a table scan when searching. Further, each index would not be particularly selective since there are only three possible values per index. Is there a better way to approach this problem?

    Read the article

  • How to generate a monotone MART ROC in R?

    - by user1521587
    I am using R and applying MART (Alg. for multiple additive regression trees) on a training set to build prediction models. When I look at the ROC curve, it is not monotone. I would be grateful if someone can help me with how I should fix this. I am guessing the issue is that initially, MART generates n trees and if these trees are not the same for all the models I am building, the results will not be comparable. Here are the steps I take: 1) Fix the false-negative cost, c_fn. Let cost = c(0, 1, c_fn, 0). 2) use the following line to build the mart model: mart(x, y, lx, martmode='class', niter=2000, cost.mtx=cost) where x is the matrix of training set variables, y is the observation matrix, lx is the matrix which specifies which of the variables in x is numerical, which one categorical. 3) I predict the test set observations using the mart model found in step 2 using this line: y_pred = martpred(x_test, probs=T) 4) I compute the false-positive and false-negative errors as follows: t = 1/(1+c_fn) %threshold based on Bayes optimal rule where c_fp=1 and c_fn. p_0 = length(which(y_test==1))/dim(y_test)[1] p_01 = sum(1*(y_pred[,2]t & y_test==0))/dim(y_test)[1] p_11 = sum(1*(y_pred[,2]t & y_test==1))/dim(y_test)[1] p_fp = p_01/(1-p_0) p_tp = p_11/p_0 5) repeat step 1-4 for a new false-negative cost.

    Read the article

  • Replace carriage returns and line feeds in out.println?

    - by Mike
    I am a novice coder and I am using the following code to outprint a set of Image keywords and input a "|" between them. <% Set allKeywords = new HashSet(); for (AlbumObject ao : currentObjects) { XmpManager mgr = ao.getXmpManager(); if (mgr != null) { allKeywords.addAll(mgr.getKeywordSet()); } } //get the Iterator Iterator itr = allKeywords.iterator(); while(itr.hasNext()){ String str = itr.next(); out.println(str +"|"); } %> I want the output to be like this: red|blue|green|yellow but it prints out: red| blue| green| yellow which breaks my code. I've tried this: str.replaceAll("\n", ""); str.replaceAll("\r", ""); and str.replaceAll("(?:\\n|\\r)", ""); No luck. I'd really appreciate some help!

    Read the article

  • why my test performance class gives me inconsistent results even after proper warm-up?

    - by colinfang
    i made a class which helps me measure time for any methods in Ticks. Basically, it runs testing method 100x, and force GC, then it records time taken for another 100x method runs. x64 release ctrl+f5 VS2012/VS2010 the results are following: 2,914 2,909 2,913 2,909 2,908 2,907 2,909 2,998 2,976 2,855 2,446 2,415 2,435 2,401 2,402 2,402 2,399 2,401 2,401 2,400 2,399 2,400 2,404 2,402 2,401 2,399 2,400 2,402 2,404 2,403 2,401 2,403 2,401 2,400 2,399 2,414 2,405 2,401 2,407 2,399 2,401 2,402 2,401 2,404 2,401 2,404 2,405 2,368 1,577 1,579 1,626 1,578 1,576 1,578 1,577 1,577 1,576 1,578 1,576 1,578 1,577 1,578 1,576 1,578 1,577 1,579 1,585 1,576 1,579 1,577 1,579 1,578 1,579 1,577 1,578 1,577 1,578 1,576 1,578 1,577 1,578 1,599 1,579 1,578 1,582 1,576 1,578 1,576 1,579 1,577 1,578 1,577 1,591 1,577 1,578 1,578 1,576 1,578 1,576 1,578 As you can see there are 3 phases, first is ~2,900, second is ~2,400, then ~1,550 What might be the reason to cause it? the test performance class code follows: public static void RunTests(Func<long> myTest) { const int numTrials = 100; Stopwatch sw = new Stopwatch(); double[] sample = new double[numTrials]; Console.WriteLine("Checksum is {0:N0}", myTest()); sw.Start(); myTest(); sw.Stop(); Console.WriteLine("Estimated time per test is {0:N0} ticks\n", sw.ElapsedTicks); for (int i = 0; i < numTrials; i++) { myTest(); } GC.Collect(); string testName = myTest.Method.Name; Console.WriteLine("----> Starting benchmark {0}\n", myTest.Method.Name); for (int i = 0; i < numTrials; i++) { sw.Restart(); myTest(); sw.Stop(); sample[i] = sw.ElapsedTicks; } double testResult = DataSetAnalysis.Report(sample); for (int j = 0; j < numTrials; j = j + 5) Console.WriteLine("{0,8:N0} {1,8:N0} {2,8:N0} {3,8:N0} {4,8:N0}", sample[j], sample[j + 1], sample[j + 2], sample[j + 3], sample[j + 4]); Console.WriteLine("\n----> End of benchmark"); }

    Read the article

  • Feature panel hover changer effect

    - by user1519157
    Haven't seen this before so hopefully someone has a easy solve, I have a 3 feature panel divs side by side, what I want happen is the 1st panel has a "hover" class added so I can change the background etc and then on a timed interval the hover class jumps to the next panel then the next panel then back to the start on a loop. Also on a side note can you keep the code in mind to be able to add more then 3 feature divs so you could have for example 6 or more or less etc.

    Read the article

  • unicode data with custom font doesn't work properly in ipad

    - by David Ohanyan
    I am using custom font for label and string which I am getting from unicode characters. And the font is not changing. here is the snippet of my code: NSString* str = @"\u05D0\u05D1\u05D2"; [mMatchingLabel setText:str]; mMatchingLabel.font = [UIFont fontWithName:@"David New Hebrew" size:26]; But when I write for example : NSString* str = @"label"; [mMatchingLabel setText:str]; mMatchingLabel.font = [UIFont fontWithName:@"David New Hebrew" size:26]; The font effect is evident. Can someone explain what's here wrong?

    Read the article

  • Unexpected result when comparing ints

    - by Raghav
    I tried to compare two ints with the following cases and got unexpected results when I did the following, @@@ was printed. class C { static Integer a = 127; static Integer b = 127; public static void main(String args[]){ if(a==b){ System.out.println("@@@"); } } } when I did the following, @@@ was not printed. class C { static Integer a = 145; static Integer b = 145; public static void main(String args[]){ if(a==b){ System.out.println("@@@"); } } } Can anyone tell me what could be the reason.

    Read the article

  • How to integrate existing Wordpress blog into Magento

    - by jcmeghan
    Our company has an existing Wordpress blog which I would like to integrate into our new Magento site. I'm not finding much luck out there on the interwebs, so I was hoping someone might be able to direct me to the best way of doing what i need here. All I need is to show the latest 5 posts on my page. It can either be done via an RSS feed or some other method, but I would prefer to not install Wordpress on the same server so as to lag down my sites server. Any ideas or thoughts would be greatly appreciated. Thanks, Meghan

    Read the article

  • what is the wrong with this spec and controller code?

    - by user1609468
    I'm trying to test an existing rails project with rspec. And I want to test a controller but getting an error which I can't solve :S Here is the my spec code ; require 'spec_helper' describe BriefNotesController do before(:all) do @customer=Factory(:customer) @project=Factory(:project_started, :owner => @customer) end context 'get :new' do it 'should redirect to login page for not signed in users' do get :new, :project_id => @project.id response.should redirect_to("/kullanici-girisi") end it 'should be success and render new brief note page for project owner' do sign_in @customer get :new, :project_id => @project.id response.should be_success end end end Here is the my controller code ; class BriefNotesController < ApplicationController before_filter :authenticate_user! before_filter :find_project def new @brief_note = @project.brief_notes.new end def create @brief_note = @project.brief_notes.build(params[:brief_note]) if @brief_note.save redirect_to brief_project_path(@project) else render :action => :new end end private def find_project @project = current_user.projects.find_by_cached_slug([params[:project_id]]) end end I think current_user.projects.find_by_cached_slug method don't work. So this is the error; Failures: 1) BriefNotesController get :new should be success and render new brief note page for project owner Failure/Error: get :new, :project_id => @project.id NoMethodError: undefined method `brief_notes' for nil:NilClass # ./app/controllers/brief_notes_controller.rb:6:in `new' # ./spec/controllers/brief_notes_controller_spec.rb:19:in `block (3 levels) in <top (required)>'

    Read the article

  • php parsing xml result from ipb ssi tool

    - by Sir Troll
    Last week my code was running fine and now (without changing anything) it is no longer able to parse the elements out of the XML. The response from the ssi tool: <?xml version="1.0" encoding="ISO-8859-1"?> <ipbsource><topic id="32"> <title>Test topic</title> <lastposter id="1">Drake</lastposter> <starter id="18">Drake</starter> <forum id="3">Updates</forum> <date timestamp="1345600720">22 August 2012 - 03:58 AM</date> </topic> </ipbsource> enter code here Update: Switched to SimpleXML but I can't extract data from the xml: $xml = file_get_contents('http://site.com/forum/ssi.php?a=out&f=2&show=10&type=xml'); $xml = new SimpleXMLElement($xml); $item_array = array(); var_dump($xml); foreach($xml->topic as $el) { var_dump($el); echo 'Title: ' . $el->title; } The var_dump output: object(SimpleXMLElement)#1 (1) { [0]=> string(1) " " }

    Read the article

  • Liquid Layout: 100% max-width img not applied - why?

    - by MEM
    I'm totally new to this liquid layout stuff. I've notice, as most of us, that while most of my layout components "liquify", images, unfortunately, don't. So I'm trying to use the max-width: 100% on images as suggested on several places. However, and despite the definition of max-width and min-height of the img container, the img don't scale. Sample code: CSS img { max-width: 100%; } article { float: left; margin: 30px 1%; max-width: 31%; min-height: 350px; } HTML <article> <header> <h2>some header</h2> </header> <img src="/images/thumb1.jpg" alt="thumb"> <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin vel ante a orci tempus eleifend.</p> </article> Please have a look on the following link: http://tinyurl.com/d849f8x If you see it on a wide resolution, you will notice that the "kid image", for example, don't scale. Any clue about what could the issue be, why does that image not scale? Test case: Browsers: Firefox 15.0 / Chrome 21.0 IOS: MAC OS X Lion - 10.7.3 Resolution: 1920x1200 What I get: I get an image that doesn't scale until the end of it's container. The img width won't fit the article element that contains it. What I do expect: I expect the image to enlarge, until it reaches the end it's container. Visually, I'm expecting the image to be as wide as the paragraph immediately below, in a way that, the right side of the image stays vertically aligned with the right side of the paragraph below.

    Read the article

  • Unable to Redirecting to a subdomain after logIn from another subdomain in MVC4

    - by Nash
    Expect behaviour :: User has to login from aut.mycompany.local and after login he must be redirected to my.mycompany.local. Redirecting Code after validating the user credentials return RedirectToAction("Index", @"plportal/account", new { subdomain = "my" }); Actual Subdomain URL http://my.mycompany.local/plportal/account But I'm getting belwo error: System.DirectoryServices.DirectoryServicesCOMException: There is no such object on the server. PLease help me and thanks in advance

    Read the article

  • Creating nested fields for column on assignment table?

    - by H O
    I have three models, that represent a many to many relationship - Product, Sale and Product_sale. I have a nested form that allows me to create new products from the sale form - so far, so good. I have, however, added some additional fields to the assignment table - price, for example. How can I set the price on the assignment table from the product form, when it is nested in the sale form? I currently have the code below: <%= sale.fields_for :products do |products_builder| %> <%= render :partial => "products/form", :locals => {:f => products_builder, :form_actions_visible => false} %> <% end -%> I could nest a Product_sale form within the product form, but this would create a new product_sale, which is not what I am looking for. I will most likely need to nest the price field within the product form, to ensure that it updates the correct assignment record (since there could be multiple products on one sale form). How can I use a fields_for loop on the product form to update the existing assignment record that is built when I do @sale.products.build? The assignment record will not yet be saved, so I can not access it using a where clause and edit it that way. Thanks!

    Read the article

  • How to do something when AVQueuePlayer finishes the last playeritem

    - by user1634529
    I've got an AVQueuePlayer which I'm creating from an array of 4 AVPlayerItems, and it all plays fine. I want to do something when the last item in the queue finishes playing, I've looked a load of answers on here and this is the one that looks most promising for what I want: The best way to execute code AFTER a sound has finished playing In my button handler i have this code: static const NSString *ItemStatusContext; [thePlayerItemA addObserver:self forKeyPath:@"status" options:0 context:&ItemStatusContext]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd) name:AVPlayerItemDidPlayToEndTimeNotification object:thePlayerItemA]; theQueuePlayer = [AVQueuePlayer playerWithPlayerItem:thePlayerItemA]; [theQueuePlayer play]; and then I have a function to handle playerItemDidReachEnd: - (void)playerItemDidReachEnd:(NSNotification *)notification { // Do stuff here NSLog(@"IT REACHED THE END"); } But when I run this I get an Internal Inconsistency Exception: An -observeValueForKeyPath:ofObject:change:context: message was received but not handled. Key path: status Observed object: <AVPlayerItem: 0x735a130, asset = <AVURLAsset: 0x73559c0, URL = file://localhost/Users/mike/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/A0DBEC13-2DA6-4887-B29D-B43A78E173B8/Phonics%2001.app/yes.mp3>> Change: { kind = 1; } What am I doing wrong?

    Read the article

  • How to update the contents of a FigureCanvasTkAgg

    - by Copo
    I'm plotting some data in a Tkinter FigureCanvasTkagg using matplotlib. I need to clear the figure where i plot data and draw new data when a button is pressed. here is the plotting part of the code (there's an App class defined before..) self.fig = figure() self.ax = self.fig.add_subplot(111) self.ax.set_ylim( min(y), max(y) ) self.line, = self.ax.semilogx(x,y,'.-') #tuple of a single element self.canvas = FigureCanvasTkAgg(self.fig,master=master) self.ax.semilogx(x,y,'o-') self.canvas.show() self.canvas.get_tk_widget().pack(side='top', fill='both', expand=1) self.frame.pack() how do i update the contents of such a canvas? regards, Jacopo

    Read the article

  • how do I make my submenu position dynamic based on the distance to the edge of the window?

    - by Mario Antoci
    I'm trying to write a jQuery script that will find the distance to the right edge of the browser window from my css class element and then position the child submenu dropdowns to the right or left depending on the available space to the right. Also it needs to revert to the default settings on hoverout. Here is what I have so far but it's not calculating properly. $(document).ready(function(){ $('#dnnMenu .subLevel').hover(function(){ if ($(window).width() - $('#dnnMenu .subLevel').offset().left - '540' >= '270') { $('#dnnMenu .subLevelRight').css('left', '270px');} else {$('#dnnMenu .subLevelRight').css('left', '-270px');} }); $(document).ready(function () { function HoverOver() { $(this).addClass('hover'); } function HoverOut() { $(this).removeClass('hover'); } var config = { sensitivity: 2, interval: 100, over: HoverOver, timeout: 100, out: HoverOut }; $("#dnnMenu .topLevel > li.haschild").hoverIntent(config); $(".subLevel li.haschild").hover(HoverOver, HoverOut); }); Basically I tried to take the width of the current window, minus the distance to the left edge of the browser of the first level submenu, minus the width of both elements together which would equal 540px, to calculate the distance to the right edge of the window when the first level submenu is hovered over. if the distance to the right of my first level submenu element is less than 540px then the second level sub menu css property is changed to position to the left instead of right. I also know that it needs to revert back to default after hover out so it can recalculate the distance from other positions within the menu structure and still have those second level submenus with enough room to still display on the right of the first level. here is css for the elements in question. #dnnMenu .subLevel{ display: none; position: absolute; margin: 0; z-index: 1210; background: #639ec8; text-transform: none;} #dnnMenu .subLevelRight{ position: absolute; display: none; left: 270px; top: 0px;} The site's not live yet and I tried to create a jsfiddle but it doesn't look right. Any help would be greatly appreciated! Best Regards, Mario

    Read the article

  • Headless gem: webkit_server: cannot connect to X server

    - by 23tux
    I've got some problems running capybara-webkit with the Headless gem, Xvfb and our ci server. We use this setup for automatic integration testing and javascript testing of our Ruby on Rails 3.2 app. During the tests it complains that webkit_server: cannot connect to X server But when I ps aux | grep Xvfb deploy 1602 0.0 0.1 61696 1912 pts/2 S+ Jul10 0:00 /usr/bin/Xvfb :99 -screen 0 1280x1024x24 -ac I see the Xvfb running. If I run the tests with --trace it also only shows the error log above and I can't debug the error. Any ideas how I could get some more information, or even a solution?

    Read the article

  • How to reduce the time of clang_complete search through boost

    - by kirill_igum
    I like using clang with vim. The one problem that I always have is that whenever I include boost, clang goes through boost library every time I put "." after a an object name. It takes 5-10 seconds. Since I don't make changes to boost headers, is there a way to cache the search through boost? If not, is there a way to remove boost from the auto-completion search? update (1) in response to answer by adaszko after :let g:clang_use_library = 1 I type a name of a variable. I press ^N. Vim starts to search through boost tree. it auto-completes the variable. i press "." and get the following errors: Error detected while processing function ClangComplete: line 35: Traceback (most recent call last): Press ENTER or type command to continue Error detected while processing function ClangComplete: line 35: File "<string>", line 1, in <module> Press ENTER or type command to continue Error detected while processing function ClangComplete: line 35: NameError: name 'vim' is not defined Press ENTER or type command to continue Error detected while processing function ClangComplete: line 40: E121: Undefined variable: l:res Press ENTER or type command to continue Error detected while processing function ClangComplete: line 40: E15: Invalid expression: l:res Press ENTER or type command to continue Error detected while processing function ClangComplete: line 58: E121: Undefined variable: l:res Press ENTER or type command to continue Error detected while processing function ClangComplete: line 58: E15: Invalid expression: l:res Press ENTER or type command to continue ... and there is no auto-compeltion update (2) not sure if clang_complete should take care of the issue with boost. vim without plugins does search through boost. superuser has an answer to comment out search through boost dirs with set include=^\\s*#\\s*include\ \\(<boost/\\)\\@!

    Read the article

  • Take advantage of multiple cores executing SQL statements

    - by willvv
    I have a small application that reads XML files and inserts the information on a SQL DB. There are ~ 300 000 files to import, each one with ~ 1000 records. I started the application on 20% of the files and it has been running for 18 hours now, I hope I can improve this time for the rest of the files. I'm not using a multi-thread approach, but since the computer I'm running the process on has 4 cores I was thinking on doing it to get some improvement on the performance (although I guess the main problem is the I/O and not only the processing). I was thinking on using the BeginExecutingNonQuery() method on the SqlCommand object I create for each insertion, but I don't know if I should limit the max amount of simultaneous threads (nor I know how to do it). What's your advice to get the best CPU utilization? Thanks

    Read the article

  • Google Games Chat #3!

    Google Games Chat #3! The Google Games Chat is back! Now with a little bit of structure! Come check out the hot new property that Web Pro News raved "a show", and what we here at Google call "45 minutes away from doing real work." We'll be chatting about games, industry trends, and making bold new predictions that will probably look ridiculously wrong in three years. As always, please ask questions in the Google Moderator section below, and we might even get around to answering one or two. From: GoogleDevelopers Views: 0 0 ratings Time: 00:00 More in Science & Technology

    Read the article

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