w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Beautiful Soup - Print a containers text without printing the text of the child elements
Select div element that is above and use nextSibling: from bs4 import BeautifulSoup html = '<div id="product-short-summary-wrap"> <b class="tip-anchor tip-anchor-wrap">Short summary description Toshiba Satellite Pro C850-1GR</b>ev : <br/> <div class="tooltip-text">This short summary of the data-sheet.</div> Toshiba Satellite Pro C850-1GR Satellite Pro, 1.8 GHz </div>' soup = BeautifulSoup(html) text = soup.find("div", {"class":"tooltip-text"}) print text.nextSibling.string Output: Toshiba Satellite Pro C850-1GR Satellite Pro, 1.8 GHz If div has This short summary of the data-sheet in it, then you can try this: from bs4 import BeautifulSoup html = '<div id="product-short-summary-wrap"> <b class="tip-anchor tip-anchor-wrap">

Categories : Python

WPF - overlay text on top of datagrid row
If your rows have fixed height, you could add a another transparent datagrid on top of the other datagrid. The transparent datagrid would have one column which would show the disabled explanation. Simple but hacky solution. The proper way would be to use adorners. Here's an example of a datagrid with adorners.

Categories : Wpf

Text alignment in DataGrid
You need set DataGridCell style <DataGrid> <DataGrid.Columns> <DataGridTextColumn> <DataGridTextColumn.ElementStyle> <Style TargetType="TextBlock"> <Setter Property="HorizontalAlignment" Value="Center" /> </Style> </DataGridTextColumn.ElementStyle> </DataGridTextColumn> </DataGrid.Columns> </DataGrid>

Categories : Wpf

how to change of text in datagrid after selecting a row only, FLEX
See: docs. You can change styles in declaration tag or in CSS or in AS3. For example, for "Spark" and "Mobile Spark" themes: <s:DataGrid selectionColor="#FFCC00"> Also see "Styling rows and columns" docs for old Flex 3.x if needed.

Categories : Actionscript

How to access datagrid template column textbox text WPF C#
To find a control in a DataGrid template column, you should use FindChild(): public static T FindChild<T>(DependencyObject parent, string childName) where T : DependencyObject { if (parent == null) { return null; } T foundChild = null; int childrenCount = VisualTreeHelper.GetChildrenCount(parent); for (int i = 0; i < childrenCount; i++) { var child = VisualTreeHelper.GetChild(parent, i); T childType = child as T; if (childType == null) { foundChild = FindChild<T>(child, childName); if (foundChild != null) break; } else if (!string.IsNullOrEmpty(childName)) {

Categories : Wpf

Text not printing
Try this: Scanner input = new Scanner (System.in); while(true){ System.out.println("Enter a choice:"); System.out.println("+ to add"); ...... if (userPick.equals("Yes")) { System.out.println("Ok."); } else if (userPick.equals("No")) { System.exit(0); } } } It will continue to loop around the logic until the terminating condition is met. You may also like to close the scanner before System.exit(); and before any termination in fact.

Categories : Java

Position a listview control when Datagrid cell text change in wpf
You get the poition of your ListViewItem like so: FrameworkElement item = (FrameworkElement)DataGrid.ItemContainerGenerator.ContainerFromItem(data); Point position = item.TranslatePoint(new Point(0, item.ActualHeight), Window.GetWindow(DataGrid)); Now you can change the position of your ListView: ListView.RenderTransform = new TranslateTransform(position.X, position.Y); EDIT: You can also use the EventArgs of you BeginningEdit-Event: private void DataGrid_OnBeginningEdit(object sender, DataGridBeginningEditEventArgs e) { Point newPosition = new Point(); if (!(lstvwProductCode.RenderTransform is TransformGroup)) lstvwProductCode.RenderTransform = new TransformGroup();// set the ListView's RenderTransform to a TransformGroup if it isn't already

Categories : C#

Printing Picture and Text
Use DrawImage method: e.Graphics.DrawImage(pictureBox.Image, new Point(10, 10));

Categories : C#

SDL - Printing text like a console?
This isn't a trivial thing to do, but it sounds like a good learning project! You're maybe going to need a few thousand lines of code rather than the few tens you have up there. Perhaps start by considering these questions and their answers. Do you want a fixed width font, or a variable width font? How can you buffer the rendered text in an intelligent way? (glyphs or lines for eg.) How can you buffer the text itself in an intelligent way? How can you translate key presses into text? What is translating and driving all this? All these will need to be considered along with the most important question of all: Do I want to do this? If you do do this, it will teach you a lot about programming, but it might not give you the best full screen console you're looking for.

Categories : C++

Change the assigned function and text to a button in a WPF Datagrid depending on column value
Create a property in your code behind or view model and bind it to the Button.Content property: <Button Click="UpdateTopic" Content={Binding ButtonText}" /> Assuming that you have access to your data objects bound to the DataGrid as the column value changes, edit the method in your code behind that is linked to the Button.Click event to something like this: public void UpdateTopic() { if (columnValue == "Something") DoSomething(); else if (columnValue == "SomethingElse") DoSomethingElse(); else if (columnValue == "AnotherThing") DoAnotherThing(); } This way, you can have one click handler that performs a variety of duties dependant on the current value of the column.

Categories : C#

Printing text after searching for a string
You can use string formatting here with the use of the str.format() function: def findFruit(f): found = re.search(r'.*? (.*?) Lemon (.*?) .*?$', f) if found is not None: print '"{}" # "{}"'.format(found.group(1), found.group(2)) Or, a lovely solution Kimvais posted in the comments: print '"{0}" # "{1}"'.format(*found.groups()) I've done some edits. Firstly, a for-loop isn't needed here (nor is a list comprehension. You're iterating through each letter of the string, instead of each word. Even then you don't want to iterate through each word. I also changed your regular expression (Do note that I'm not that great in regex, so there probably is a better solution).

Categories : Python

Javascript text printing order
Switch the HTML element's id. As the function name implies, the getElementById function gets you the HTML element with the given id (if exists, else null). This document.getElementById("demo1") refers to <p id="demo1">This is a paragraph.</p> And document.getElementById("demo") refers to <p id="demo">This is demo1.</p> Since the elements in your HTML are in the order <p id="demo1">This is a paragraph.</p> <p id="demo">This is demo1.</p> you must target demo1 to change the first and demo to change the second paragraph's inner HTML. Thus, either change the ids in your JS function call, or in your HTML. Reference: https://developer.mozilla.org/en-US/docs/Web/API/document.getElementById

Categories : Javascript

Invalid Type Text Keeps Printing
public static void game(int number) { while (true) { try{ System.out.print("Guess a number: "); // prompt user to enter an int inputStorage = input.nextInt(); // read the number if (inputStorage == number) { System.out.println("You've won!"); break; } else { System.out.println("Wrong number! Try again."); } } catch(final Exception ignored) { // input was not a number System.out.println(" Only numbers! Try again."); input.next(); // consume the invalid input } } } This will prompt the user to enter a number and only tell the user that they need to enter a number if one wasn't presented. If the user doesn't enter a

Categories : Java

Printing string text in C does not print
I think you are misunderstanding that code. The code you submitted writes a string "This is a test printing" to a file in the same directory called "lpt1". What you are probably wanting is to write out to something like "/dev/lpt1", and you should be able to test this by running echo "this is my printed text" >/dev/lpt1

Categories : C

Printing rotated text from web page
You can use PHP to generate an image of the rotated text and then print it. The cool thing about images is that it doesn't depend upon the browser at all. There are some solutions (already mentioned in this thread) that work, but are tested only on few latest browsers. This solution doesn't care about the browser as long as the browser can print images, only it bothers about a server that can support PHP5. here's how your PHP file (image_gen.php) should look: <?php // create a 100*100 image $im = imagecreatetruecolor(100, 100); // Write the text $textcolor = imagecolorallocate($im, 0xFF, 0xFF, 0xFF); imagestringup($im, 3, 40, 80, $_GET['text'], $textcolor); header('Content-type: image/png'); // Save the image imagepng($im); imagedestroy($im); ?> See this link... This file takes

Categories : PHP

printing a note pad text file
The PritnDocument will fire the PrintPage event for every page that needs to be printed. You can hook into that event and "Draw" your page. In your case, draw a string for every line in the text file. Font printFont = new Font("Arial", 10); StreamReader Printfile; private void button6_Click(object sender, EventArgs e) { using(StreamReader Printfile = new StreamReader("c:\testDir1\Password.txt)) { try { PrintDocument docToPrint = new PrintDocument(); docToPrint.DocumentName = "Password"; //Name that appears in the printer queue docToPrint.PrintPage += (s, ev) => { float linesPerPage = 0; float yPos = 0; int count = 0; float leftMargin = ev.MarginBounds

Categories : C#

DataGrid edition 'EditItem' is not allowed for this view` when bound to a WPF DataGrid
I tried this and the problem is that you have initialized your Level2 collection as Hashset<>. IEditableCollectionView.EditItem() throws this error while trying to update item in Hashset<>. I initialized the collection as List<> and it was working fine. I am not sure why it is not able to update item in hashset, need to look deeper into it. But changing the Hashset<> to List<> will fix this error. Hope it helps Thanks

Categories : C#

Silverlight Datagrid scrolling, DataGrid fires RowLoading event
The RowLoading event is fired because rows are virtualized. With virtualization, rows are created (and loaded) only when they are visible on screen. So every time you scroll down or up a new row is created, loaded and the RowLoading event fired. To disable the virtualization you can try to set this property: VirtualizingStackPanel.VirtualizationMode="Standard" Be aware that this can slow down the performance of your grid if you have a lot of rows.

Categories : Database

Splitting and printing a text file as links
you can try echo "<table>"; foreach($fileContentsArray as $one_link) { echo '<tr>'; list($name, $link) = explode(",", $one_link); echo "<td><a href="$link">$name</a></td>"; echo '</tr>'; } echo "</table>";

Categories : PHP

Text File Reading and Printing Data
This should work.. with open('MyText.txt', 'r') as f: lineArr=f.read().split(' ') if 'Sample Text' in lineArr: timeTaken = [s for s in lineArr if "Time Taken" in s] print timeTaken[0]

Categories : Python

Need help printing query results to a file/text
You need to select "Results to File" not "Results to Text". When you then go back and run your query, you will not see any query results, just a prompt for the file name you want to save the results as.

Categories : Sql Server

Printing variable and text with input command?
The input() function takes only one string argument (and not multiple, like print()). Use string formatting: answer = int(input('{} + {} = '.format(oneTerm, twoTerm))) The {} placeholders are replaced by the two arguments to .format(), creating essentially the same string to prompt the user for input. See the str.format() method documentation for more details.

Categories : Python

Stuck on Ruby foreach printing text at the end
You are reading the file and printing <servicedef> and <hours> for each line. If you want to write all <servicedef> tags, then all <hours> tags, I suggest you first load the file, remember what you want to remember in an array, then loop through it twice. Something similar to this: lines = source.lines lines.each do |access| builder.servicedef { |b| b.hostname(""); } end lines.each do |access| hid += 1 builder.hours(:hoursID => "#{hid}") { } end Also note that you're not closing your file. It is a good practice to do your file reading in a block, so your file will autoclose when you want it to, rather than keeping the handle open until your code terminates: lines = File.open("host.txt") { |source| source.lines }

Categories : Ruby

reading and printing a text file in Perl
Because you are comsuming the first line with the <> operator and then using it again in the print, so the first line has already gone but you are not printing it. <> is the readline operator. You need to print the $_ variable, or assign it to a defined variable as you are doing in the second code. You could rewrite the first: print; And it would work, because print uses $_ if you don't give it anything.

Categories : Perl

Printing out different color text with each button press?
You could solve this by implementing a generator that returns a value from a collection of colors every time next is called on it: from itertools import repeat def get_color_generator(): # This will return a tuple with the colors on each iteration COLORS = repeat(("blue", "red", "yellow")) # This will never terminate ('repeat' without a second argument # creates an endless generator) for color_set in COLORS: for color in color_set: yield color color_generator = get_color_generator() def b1(): bl = Label(master, text="Hell yeah!", fg=next(color_generator), bd = 3).pack() If the order of the colors does not matter, it is even easier: from random import choice COLORS = ("blue", "red", "yellow") def b1(): bl = Label(master, text="H

Categories : Python

Binding ComboBoxColumn to collection from DataGrid's ItemsSource in WPF DataGrid
MSDN: DataGridComboboxColumns says: To populate the drop-down list, first set the ItemsSource property for the ComboBox by using one of the following options: A static resource. For more information, see StaticResource Markup Extension. An x:Static code entity. For more information, see x:Static Markup Extension. An inline collection of ComboBoxItem types. So basically to just bind to data object`s collection property it`s better to use DataGridTemplateColumn: <DataGridTemplateColumn Header="Log"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding log}" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> This type of c

Categories : Wpf

Reading and printing from a plain text file Python 3
What your file contains is almost exactly the Python syntax for a list of strings, it's just missing the [ and ]. If you add these, you can use ast.literal_eval to safely evaluate the Python syntax and give you the list of strings: >>> from ast import literal_eval >>> with open('myfile.txt', 'r') as f: file_contents = f.read() >>> literal_eval('[' + file_contents + ']') [' Test1 Test1 Test1 ', ' Test2 Test2 Test2 ', ' Test3 Test4 Test5 ']

Categories : Python

Incorrect text colors when printing HTML page
Check this Fiddle You have to use -webkit-print-color-adjust on the element which you are going to print Also check here to know more about print color adjust https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust

Categories : CSS

Printing multiple text strings from single cell
Here is my proposed solution, using the Split function and a collection. Sub Reference() ' Disable screen updating Application.ScreenUpdating = False Dim wS As Worksheet Set wS = ActiveSheet ' you can change it to be a specific sheet Dim i As Long Dim LastRow As Long LastRow = Range("D" & Rows.Count).End(xlUp).Row Dim Dpts As Variant Dim dFullText As Variant Dim LookUp As New Collection ' Create a collection where the key is the shortcode and the value is the full name of the dpt On Error Resume Next For i = 3 To 11 LookUp.Add wS.Cells(i, 17), wS.Cells(i, 16) Next i On Error GoTo 0 ' Loop on each row For i = 10 To LastRow Dpts = Split(wS.Cells(i, 4), ",") ' Split creates an array ' First case dFullText = LookUp.Item(Trim(Dpts(0))) ' TRIM = remove traili

Categories : Excel

printing a column after a specific pattern from a text file
This should work: awk '{for(i=1;i<=NF;i++) if($i~/A|C|D/) printf $++i FS; print ""}' file Output: $ awk '{for(i=1;i<=NF;i++) if($i~/A|C|D/) printf $++i FS; print ""}' file 0.0400213 0.047396 0.082056 0.0275027 0.023266 0.0406213 0.0310553 0.0210907 0.05332 0.03491 0.020474 0.0570167 0.0485573 0.00938133 0.0519087 More verbose: $ awk '{for(i=1;i<=NF;i++) if($i~/A|C|D/) { gsub(/[(]/,"",$i) ; printf $i " is " $++i FS }; print ""}' file A is 0.0400213 C is 0.047396 D is 0.082056 C is 0.0275027 A is 0.023266 D is 0.0406213 C is 0.0310553 A is 0.0210907 D is 0.05332 C is 0.03491 A is 0.020474 D is 0.0570167 C is 0.0485573 A is 0.00938133 D is 0.0519087 Update: $ awk '{for(i=1;i<=NF;i++)if($i~/A/){gsub(/[(]/,"",$i);print $++i}}' file 0.0400213 0.023266 0.0210907 0

Categories : Regex

Removing Spaces in Perl when Printing to a text file
In modern perl: you use the three argument form of open() you use my variables instead of bareword filehandles and you output the system error message ($!) when things go wrong: open my $INFILE, '<', $fname or die "Couldn't open $fname: $!"; You have to print line by line. You can't print one column and then another column. So when you do this: printf FILE ( "%-s %-s %-s %-s ", $data->{"spectrum-index"}, $data->{tic}, $spectrum->{'content'}, $data1->{duration} ); ... then of course all that data is going to be on one line.

Categories : Perl

Python printing Formatted text with lists nested in dict
Something like this: processors_info = " ".join(machine_info['processors']) print "Processor(s): {}".format(processors_info) Demo: >>> info = ['processor_1_info', 'processor_2_info'] >>> processors_info = " ".join(info) >>> print "Processor(s): {}".format(processors_info) Processor(s): processor_1_info processor_2_info Another way using string formatting: info = ['processor_1_info', 'processor_2_info', 'processor_3_info'] #info = machine_info['processors'] for your code. print "Processor(s):{:>20s}".format(info[0]) for item in info[1:]: print "{:>33s}".format(item) output: Processor(s): processor_1_info processor_2_info processor_3_info

Categories : Python

Printing text from BeautifulSoup object, excluding certain tags? [Python 2.7]
Use a class that builds on a module from Python's stdlib... from HTMLParser import HTMLParser class HTML_tag_stripper(HTMLParser): def __init__(self): self.reset() self.fed = [] def handle_data(self, d): self.fed.append(d) def get_data(self): return ''.join(self.fed) def strip_tags(html): s = HTML_tag_stripper() s.feed(html) return s.get_data() >>> print strip_tags( str(soup) )

Categories : Python

Printing out each line of a text file in Java that only contains a specific String?
You will want to break the problem down into steps. For instance: Figure out how to read each line of text in a file. A Scanner object will work nicely for this and you can find the Scanner API at the link I've provided. Look at using a while loop, Scanner's hasNextLine() and nextLine() method to get you going. Figure out how to see if the String obtained above contains "OK". There's a nice String method that the String API will help you with. Figure out how to print the line if it passes the above test. An if block will help here. I think that you already know how to use System.out.println(...) When done, dispose of the Scanner, tidy up... And voilà, there it is!

Categories : Java

Rails printing address labels in text file in this format
If you can guarantee the width of each line in a column will not exceed the width of the column, you can create padded strings using sprintf. Each of your columns is 37 characters wide, so to print three columns, the command would be sprintf("%-37s%-37s%-37s", col1,col2,col3). You would have to repeat that for each field. That's assuming you have a string already for each line. You will need to generate each string from your data for things like concatenating the prefix with the name.

Categories : Ruby On Rails

Comparing two lines in text file & printing single line corresponding to similar dates
This is basic data parsing. In pseudo code this is how I would do it Create a class that holds 4 valus, Employee, Date, InTime, OutTime Instantiate a HashMap for all the final log lines For each log line Parse the line using RegEx to find Employee, Date and in and/or out time Create the HashKey using Employee + Date See if the HashMap already contains such an object, else create one Populate with the in and/or out times found on the current line Done, the HashMap now contains all parsed data.

Categories : Java

c++ program for reading csv writing into array; then manipulating and printing into text file (already written in matlab)
Change this line: array[row][col] = atoi( result.c_str ); to: array[row][col] = atoi( result.c_str() ); c_str() is a method, so you need parenthesis to call it. See http://en.cppreference.com/w/cpp/string/basic_string/c_str

Categories : C++

Validating A WPF Datagrid Against Data From Another Datagrid
From Microsoft official WPF course materials: ValidationRules are only to be used as simple validations (For instance Required fields, numeric formats, etc). If you need advanced / complex Business Rules validation, you should either implement IDataErrorInfo or create your own validation mechanism (that's what I did and it works like a charm)

Categories : C#

Copy selected row from datagrid at the end of datagrid
For Datagridview Databound you have to commit additional record to datasource (table) So, you have to do "INSERT INTO mytable ( fields here ... ) VALUES ( values here ..)" then to refresh your datagridview .. dt2.datasource = mytable ADDED : For your code ... try change like this insert_cmd.Parameters.AddWithValue("@Name", .item("Name")) insert_cmd.Parameters.AddWithValue("@Age", .item("Age"))

Categories : Sql Server

DataGrid Cell (or row) selection works only when clicking on the content (the text) of the cell(s)
You really want to set the TextAlignment property to center. But unfortunately you don't have access to that property from the FrameworkElement. You're probably better off using a DataGridTemplateColumn to get the desired effect.

Categories : Wpf



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.